html - Using href links inside <option> tag with jQuery in the way -
i have following code :
<div class="dropdownmenu"> <select multiple id="cd-dropdown" name="dropdown-menu" class="cd-select"> <option value="-1" selected>social</option> <option onclick="window.location = 'http://www.twitter.com'" value="1" class="icon-monkey">twitter</option> <option onclick="window.location = 'http://www.facebook.com'" value="1" class="icon-monkey">facebook</option> </select> </div>
i tried adding link inside select box labels, values, onclick failed, realized reason stands in following jquery code :
var elname = this.$el.attr( 'name' ), elid = this.$el.attr( 'id' ), inputname = elname !== undefined ? elname : elid !== undefined ? elid : 'cd-dropdown-' + ( new date() ).gettime(); this.inputel = $( '<input type="hidden" name="' + inputname + '" value="' + value + '"></input>' ).insertafter( this.selectlabel ); this.selectlabel.css( 'z-index', this.minzindex + this.optscount ); this._positionopts();
i couldn't figure out how change code in order allow me add links.
thought jquery problem cause once remove "id="cd-dropdown" html box links working effects , designs provided jquery doesn't apply anymore.
use $('select').change()
event :
$('select[name="dropdown-menu"]').change( function(){ if ( $(this).val() == 1 ){ //'this' refers select //insert code selected url, //and call "window.location.href = url" } });
Comments
Post a Comment