- Back to Home »
- HTML , jQuery »
Posted by : Jebastin
Saturday, 14 December 2013
Note:
When using "jquery.selectbox.js" plugin the "select & option" tags will be converted into "ul li" at run time. The problem is we can not get the selected value using the normal jQuery or Javascript when we use this plugin. The following solution rectifies this situation.Here we are going to find the 'rel' attribute value of an anchor tag which is the selected option.
HTML:
- <fieldset class="sapDD medium">
- <span class="required">*</span>
- <select id="Division" name="Division" sb="37042751" style="display: none;">
- <option value="">Select a Division</option>
- <option value="example1@gmail.com" selected="selected">example1</option>
- <option value="example2@gmail.com">example2</option>
- <option value="example3@gmail.com">example3</option>
- <option value="example4@gmail.com">example4</option>
- </select>
- <div id="sbHolder_37042751" class="sbHolder" tabindex="0">
- <a id="sbToggle_37042751" href="#" class="sbToggle"></a>
- <a id="sbSelector_37042751" href="#" class="sbSelector">example1</a>
- <ul id="sbOptions_37042751" class="sbOptions" style="top: 16px; max-height: 583px; display: none;">
- <li><a href="#" rel="" class="">Select a Division</a></li>
- <li><a href="#example1@gmail.com" rel="example1@gmail.com" class="">example1</a></li>
- <li><a href="#example2@gmail.com" rel="example2@gmail.com">example2</a></li>
- <li><a href="#example3@gmail.com" rel="example3@gmail.com">example3</a></li>
- <li><a href="#example4@gmail.com" rel="example4@gmail.com">example4</a></li>
- </ul>
- </div>
- </fieldset>
jQuery:
- $(document).ready(function(){
- var Division = $("#Division").next(".sbHolder").find("a.sbSelector").text(); ;
- var DivisionEmail = $("#Division").next(".sbHolder").find("ul.sbOptions").find("a:contains('" + Division + "')").attr("rel");
- alert(DivisionEmail);
- });