Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <label>Tags<a class="required_field">*</a></label>
  2. <div id="wrapbox">
  3. <div id="box">
  4. <span id="checktags"></span>
  5. <input type="text" class="to-be-clicked" id="tags" maxlength="230">
  6. </div>
  7. </div>
  8.  
  9. $('#tags').keypress(function(e) { //Check if space was clicked, and create a new tag
  10. if(e.which == 32) {
  11. var tx = $('#tags').val();
  12. if (tx) {
  13. $(this).val('').parent().before('<li class="tags"><span><input type="hidden" value="'+tx+'" name="tags[]" />'+tx+'</span><a style="cursor:pointer;" id="close">[x]</a></li>');
  14. closer();
  15. }
  16. }
  17. });
  18.  
  19. $(function(){
  20.  
  21. var template = $('#jb').clone();
  22.  
  23.  
  24. var offersCount = 1;
  25.  
  26. window.addoffer = function(){
  27.  
  28. offersCount++;
  29.  
  30. var offer = template.clone().find(':input').each(function(){
  31.  
  32. var newId = this.id.substring(0, this.id.length-1) + offersCount;
  33.  
  34.  
  35. this.name = this.id = newId; // update id and name (assume the same)
  36.  
  37. }).end()
  38. .attr('id', 'att' + offersCount)
  39. .prependTo('#jb');
  40. }
  41. $('.add').click(addoffer);
  42. });
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement