JavaScript “Show More” Button after X buttons

Here is fiddle and this is my code:

$(document).ready(function(){
  $( ".keywordsdiv" ).each(function(){
      $(this).children(".keywords").eq(3).after('<a target='_blank' href="" id="playtrailershowmorebuttons">....Show More</a>');//add a unique id to link
      $(this).children(".keywords:gt(2)" ).addClass('hide');
  });
});

$(document).on('click','a#playtrailershowmorebuttons',function(e){
  e.preventDefault();
  $(this).addClass('hide');
  $(this).parent().children('button.keywords').removeClass('hide');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="keywordsdiv">
<a target='_blank' href="#"><button class="keywords">ABC</button></a>
<a target='_blank' href="#"><button class="keywords">CYZ</button></a>
<a target='_blank' href="#"><button class="keywords">RGRDFS</button></a>
<a target='_blank' href="#"><button class="keywords">FVFVV</button></a>
<a target='_blank' href="#"><button class="keywords">FESF</button></a>
</div>

<div class="keywordsdiv">
<a target='_blank' href="#"><button class="keywords">ABC</button></a>
<a target='_blank' href="#"><button class="keywords">CYZ</button></a>
<a target='_blank' href="#"><button class="keywords">RGRDFS</button></a>
<a target='_blank' href="#"><button class="keywords">FVFVV</button></a>
<a target='_blank' href="#"><button class="keywords">FESF</button></a>
</div>
Answer:1

You could do with find() instead of children() .because keywords not direct children of the div .

Updated jsfiddle old

$(document).ready(function() {
  $(".keywordsdiv").each(function() {
    $(this).find(".keywords").eq(3).after('<a target='_blank' href="" id="playtrailershowmorebuttons">....Show More</a>'); //add a unique id to link
    $(this).find(".keywords:gt(2)").addClass('hide');
  });
});

$(document).on('click', 'a#playtrailershowmorebuttons', function(e) {
  e.preventDefault();
  $(this).addClass('hide');
  $(this).parent().children('button.keywords').removeClass('hide');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="keywordsdiv">
<a target='_blank' href="#"><button class="keywords">ABC</button></a>
<a target='_blank' href="#"><button class="keywords">CYZ</button></a>
<a target='_blank' href="#"><button class="keywords">RGRDFS</button></a>
<a target='_blank' href="#"><button class="keywords">FVFVV</button></a>
<a target='_blank' href="#"><button class="keywords">FESF</button></a>
</div>

<div class="keywordsdiv">
<a target='_blank' href="#"><button class="keywords">ABC</button></a>
<a target='_blank' href="#"><button class="keywords">CYZ</button></a>
<a target='_blank' href="#"><button class="keywords">RGRDFS</button></a>
<a target='_blank' href="#"><button class="keywords">FVFVV</button></a>
<a target='_blank' href="#"><button class="keywords">FESF</button></a>
</div>
Answer:2

I tryed to mark text with js, i select text and then hit button that wrap the selected area with span tag - but if i select area that half of it have style, it's remove the style from the selected ...

I tryed to mark text with js, i select text and then hit button that wrap the selected area with span tag - but if i select area that half of it have style, it's remove the style from the selected ...

var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); var rect = {}; var drag = false; make_base(); init(); function make_base() { base_image = new ...

var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); var rect = {}; var drag = false; make_base(); init(); function make_base() { base_image = new ...

I have this code <span id="signinButton" class="g-signin" data-callback="signinCallback" data-clientid="...

I have this code <span id="signinButton" class="g-signin" data-callback="signinCallback" data-clientid="...

I am using qrcode.js for generating qrcode. I want to generate random QR code every time I click into add new tab instead of add new qr code. I created a code for a random number but when I try to add ...

I am using qrcode.js for generating qrcode. I want to generate random QR code every time I click into add new tab instead of add new qr code. I created a code for a random number but when I try to add ...

  1. generate random code javascript
  2. generate random code python
  3. generate random code in excel
  4. generate random code php
  5. generate random code c#
  6. generate random code java
  7. generate random code laravel
  8. generate random code online
  9. generate random code nodejs
  10. generate random code
  11. generate random code sql server
  12. generate random code sql
  13. generate random code in codeigniter
  14. generate random code vb.net
  15. generate random code numbers
  16. generate random code in swift
  17. generate random code string
  18. generate random qr code
  19. generate random color code in javascript
  20. generate random zip code