Payament
Free Photos
WordPress Themes

jQuery plugin to get all links within a container and to convert it to a dropdown list with redirection

/* use : $(selector).convertToList() it's better to follow it with .remove() to remove the original container */ (function ($) { $.fn.convertToList = function () { var that = this; this.before( $('<select><option>Please select</option></select>'). change(function () { window.location = $(this).val(); })) this.find('a').each(function () { that.prev('select').append('<option value="' + $(this).attr('href') + '">' + $(this).html() + '</option>') }); }; })(jQuery);

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.