如何使用jquery提前知道目标事件

时间:2017-02-01 16:07:11

标签: javascript jquery javascript-events event-handling

我有一个表单,其中包含textAreasbutttons两个focusout处理所有textAreas的事件click。当用户在textareas中输入任意内容时,只要save buttons事件触发按钮,我就会遇到问题,然后点击textareas仅调出textareas上的焦点,但点击事件在按钮上没有工作。以下是我对$(document).on("focusout", ".fn-enlargeTextarea", function() { // wants to capture cause event of focusout and fire after focusout. var optionNumber = ($(this).attr('id').replace('1option','')).trim(); $('#1option'+optionNumber+'_counter').remove(); $(this).removeClass('textarea-height01').addClass('textarea-height02'); }); 的关注。

                      <form id="dataPost">
                       <c:forEach items="${forumOptions}" var="option" varStatus="loop">
                                              <div class="radio m-b-15">
                                                  <label class="primary-radio row width03" for="option01-01">
                                                      <span class="primary-radio-blue col-xs-1 text-right margin-top-1">
                                                       <c:out value="${forumOptions[loop.index]}"></c:out>.</span> 
                                                      <span class="col-xs-11">
                                                          <textarea name="pollQuestionList[0].pollOptionList[${loop.index}].optionText"  id="1option${loop.index+1}" class="form-control fn-input-text fn-input-options textarea-height02"  ></textarea>
                                                      </span>
                                                  </label>
                                              </div>
                                              </c:forEach>
                      <button type="button" data-toggle="modal" data-target="#myModal" class="btn btn-dark-black cus-btn btn-preview" id="poll-save-and-preview">Save &amp; Preview</button>
                      <button type="button" class="btn btn-dark-black cus-btn" id="poll-save"> Save</button>
                      <button type="button" class="btn btn-dark-black cus-btn" id="poll-close"> Close</button>
                      <button type="button" class="btn  btn-warning  btn-font cus-btn-pad lpopup" id="poll-publish"> Post</button>
                    </form>

我刚才提前知道,如何知道引起对textareas焦点的事件,以便我可以在焦点事件消耗后立即触发目标事件。提前完成。

这里是按钮形式

clear all
webuse pig

// model
eststo: xtmixed weight week || id:, vce(robust)

// estadd portion - pull the single element of the matrix into a local and estadd it
matrix N_g = e(N_g)
local groups = N_g[1,1]
estadd local groups `groups'

// add groups in the stats option and it will appear at the bottom along
// with the number of observations in this case
esttab ., stats(N groups)

see here

1 个答案:

答案 0 :(得分:0)

如果 textarea 是固定的,那么将“.fn-enlargeTextarea”类名替换为“#1option${loop.index+1}”id属性值。