【问题标题】:When I click on a button focus goes to text area当我单击按钮时,焦点转到文本区域
【发布时间】:2016-09-05 16:52:51
【问题描述】:

我对 CSS 和 HTML 很陌生,我在这里遇到了一个非常奇怪的问题,我的 html 中有如下文本区域。

<div class="ContentBox BPMSectionBody LastContentBox noHeader" id="div_3_1_1_2_11_1_1_1_1_1_1_10_1" data-view-managed="false">

  <div class="Text_Area fullWidthTextArea CoachView CoachView_hidden CoachView_show" id="div_3_1_1_2_11_1_1_1_1_1_1_10_1_1" data-eventid="" data-viewid="Text_Area8" data-config="config99" data-bindingtype="String" data-binding="local.userAction.comments"
  data-type="com.ibm.bpm.coach.Snapshot_7a0c03cc_ccef_4582_a1bc_7ccc8e9be488.Text_Area">

    <div class="textLabel">
      <label class="text controlLabel" id="div_3_1_1_2_11_1_1_1_1_1_1_10_1_1_label">Enter Cancellation Comments</label>
      <div class="coachValidationDiv">
        <img class="coachValidationImg smallImg CoachView_hidden" role="alert" alt="Error" src="/teamworks/webasset/2064.7a0c03cc-ccef-4582-a1bc-7ccc8e9be488/W/Error_icon_24x24.png">
        <span class="coachValidationText" style="visibility: hidden;">!</span>
      </div>
    </div>
    <textarea tabindex="0" class="dijitTextBox dijitTextArea dijitExpandingTextArea BPMTextAreaFont" id="dijit_form_Textarea_16" aria-labelledby="div_3_1_1_2_11_1_1_1_1_1_1_10_1_1_label" style="-ms-overflow-x: auto; -ms-overflow-y: hidden; box-sizing: border-box;"
    rows="1" data-dojo-attach-point="focusNode,containerNode,textbox" widgetId="dijit_form_Textarea_16" autocomplete="off" value=""></textarea>
  </div>
</div>

还有一个按钮如下:

<div class="Button pageFlowButton CoachView CoachView_show" id="div_3_1_1_2_12_1_2" data-eventid="boundaryEvent_17" data-viewid="Button10" data-config="config83" data-bindingtype="" data-binding="" data-type="com.ibm.bpm.coach.Snapshot_7a0c03cc_ccef_4582_a1bc_7ccc8e9be488.Button">
  <button class="BPMButton BPMButtonBorder" type="button">Continue With Selected Action</button>
</div>

当我开始在 textarea 中输入内容并且我的光标仍然在 textarea 中并且我第一次单击按钮而不是执行操作时,文本区域会获得焦点。 当我第二次单击按钮时,它工作正常。

任何人都可以帮忙,这可能是什么原因??

【问题讨论】:

  • 按钮和文本区域是同一个表单吗?

标签: html css


【解决方案1】:

如果你使用 jQuery,我想你应该使用:

$('.Text_Area').click(function(noFocus){
  noFocus.preventDefault();
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多