Reputation: 2997
I've written a jQuery function that allows me to select an option from a dropdown using the option's HTML.
$.fn.select = function( option ) {
$(selector + ' option').each(function() {
if ($(this).text() == option)
$(selector).val($(this).val());
});
return this;
};
The function works perfectly fine, except with options that contain ampersands (&
). In this case, it will fail to properly select the corresponding option.
Is there any way I can make this work?
I am aware that there already exists a select
function for jQuery; however, it seems that my select
function is able to overwrite the existing function.
Upvotes: 1
Views: 545
Reputation: 2219
Seems to be working right with &
, Whats the problem ?
Though replacing &
with &
would be better.
Upvotes: 1