I am working on a news website and trying to show the full content of news article on click of a button.My code is
<script>
$(document).ready(function(){
$("#toggle-news-content").click(function(){
$("#news-content").fadeToggle(300);
if($("#toggle-news-content").text()=="More")
$("#toggle-news-content").text("Less");
else
$("#toggle-news-content").text("More");
});
});
</script>
<div id="news-heading"><h3>news 2 heading</h3></div>
<div id="news-content" class="news-content">news 2 content</div>
<button id="toggle-news-content">More</button>
<div id="news-heading"><h3>news 2 heading</h3></div>
<div id="news-content" class="news-content">news 2 content</div>
<button id="toggle-news-content">More</button>
Problem is when I click on the "More" button of news 1 the script is working. But it's doing nothing when I click "More" button of news 2. As the number of news is dynamic may vary time to time. Can anyone debug this code(Here I'm showing the code that causing the problem)