简体   繁体   中英

How do know target event in advance using jQuery

I have a form having couple of textAreas and buttons there is event focusout handled for all textAreas . I am facing the problem as soon as click event fire on buttons when user done typing in any of textareas and click on save buttons only focusout called on textareas , however click event on buttons didn't work. Here is my focusout on 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');     
});

I just came to know in advance that , how do know cause event of focusout on textareas so that I can fire target event as soon as focusout event consumed.

Here are the buttons inside form:

<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>

看这里

如果 textarea 已修复,则将“.fn-enlargeTextarea”类名替换为“#1option${loop.index+1}”id 属性值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM