Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* use : $(selector).convertToList() */
- (function ($) {
- $.fn.convertToList = function () {
- var that = this;
- // build selection list element and add it before our selector
- this.before(
- $('<select><option>Please select</option></select>').change(function () {
- window.location = $(this).val();
- })
- );
- // iterate each link inside our selector and add it to the
- // selection element we built above
- this.find('a').each(function () {
- that.prev('select').append('<option value="' + $(this).attr('href') + '">' + $(this).html() + '</option>');
- // hide original link
- $(this).remove();
- });
- };
- })(jQuery);
- $(document).ready(function() {
- $('.markdown-editor').convertToList();
- });
- $.fn.convertToList = function () {
- this.each(function() {
- // Plugin code here
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement