Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. /* use : $(selector).convertToList() */
  2. (function ($) {
  3. $.fn.convertToList = function () {
  4. var that = this;
  5.  
  6. // build selection list element and add it before our selector
  7. this.before(
  8. $('<select><option>Please select</option></select>').change(function () {
  9. window.location = $(this).val();
  10. })
  11. );
  12.  
  13. // iterate each link inside our selector and add it to the
  14. // selection element we built above
  15. this.find('a').each(function () {
  16. that.prev('select').append('<option value="' + $(this).attr('href') + '">' + $(this).html() + '</option>');
  17. // hide original link
  18. $(this).remove();
  19. });
  20. };
  21. })(jQuery);
  22.  
  23.  
  24. $(document).ready(function() {
  25. $('.markdown-editor').convertToList();
  26. });
  27.  
  28. $.fn.convertToList = function () {
  29. this.each(function() {
  30. // Plugin code here
  31. });
  32. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement