0

This is my html code

<c:if test="${facetList[4] == false}">
  <div class="facet_more_section" id="moresection_<c:out value='${facetSection}' escapeXml='false'/>">
    <ul id="more_<c:out value='${facetSection}' escapeXml='false'/>"></ul>
  </div>
  <div class="showMore" id="morebutton_<c:out value='${facetSection}' escapeXml='false'/>">
    <input type="checkbox" title="MORE" aria-labelledby="morelink_${facetSection}_ACCE_Label" id="morelink_${facetSection}" name="morelink_${facetSection}" value="<c:out value='${facetSection}' escapeXml='false'/>:-1" onclick="javascript: SearchBasedNavigationDisplayJS.toggleShowMore(this, '<c:out value='${facetSection}' escapeXml='false'/>');"
    style="display:none">
    <span style="background-image:url(${imageDir}/down_arrow_sprite.png);  margin-left: 3px; padding-right: 14px;cursor: pointer;" class="expand_icon_open" id="expand_icon_${facetSection}" onclick="toggle('<c:out value='${facetSection}' escapeXml='false'/>'); return false;"></span>
    <label for="morelink_${facetSection}" id="showMoreLabel_${facetSection}" style="display: inline;color:#777777;font-size: small;font-family: Arial,sans-serif;font-weight: inherit;font-style: inherit;cursor: pointer;">
      <fmt:message key="LN_SEARCH_FACET_SHOW_ALL" />
    </label>
  </div>

</c:if>

This is my jsp code

toggleShowMore: function(element, id) {
  var section = $("moresection_" + id);
  var label = $("showMoreLabel_" + id);
  section.style.display = "none";
  label.innerHTML = this.moreMsg;
  section.focus();
}

I have tried to change the focus by giving section.focus(); but not working. Please help

Rajesh
  • 24,354
  • 5
  • 48
  • 79
  • I guess `$("moresection_" + id)` should be `$("#moresection_" + id)`. If you access elements by ID, you have to prepend `#` before it – Rajesh Jul 29 '16 at 06:38
  • No Rajesh...It is not working :(...value of the section became null if I append # with that – user6649615 Jul 29 '16 at 06:51
  • I said prepend. So it should be `#` followed by id. You should try to log `section`. Also, if you are using jQuery, you should not mix approaches. You can do `label.html(this.moreMsg)` – Rajesh Jul 29 '16 at 06:59
  • not working again :( – user6649615 Jul 29 '16 at 07:16
  • A similar post: http://stackoverflow.com/questions/2704124/jquery-focus-an-element. Also can you share what was the output on console when you logged `section`? – Rajesh Jul 29 '16 at 07:17
  • Another post that might help: http://stackoverflow.com/questions/11280379/is-it-possible-to-write-onfocus-lostfocus-handler-for-a-div-using-js-or-jquery – Rajesh Jul 29 '16 at 07:18
  • It is not showing any error...It is printing the value of section as [object HTMLDivElement] – user6649615 Jul 29 '16 at 07:20

0 Answers0