<script type="text/javascript">
function displayBookInfo(str) {
if (str == "") {
document.getElementById("more-info").innerHTML="";
return;
}
if (window.XMLHttpRequest) {
// code for modern browsers
xmlhttp = new XMLHttpRequest();
}
else {
// code for older versions of Internet Explorer
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("more-info").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","showbook.php?id="+str,true);
xmlhttp.send();
}
</script>
<div class="bookProp" id="one" onClick="displayBookInfo(this.id)">
<div class="booknoHolder" id="in"> 01 </div>
</div>
<div class="bookProp" id="two" onClick="displayBookInfo(this.id)">
<div class="booknoHolder" id="in"> 02 </div>
</div>
<div class="bookProp" id="three" onClick="displayBookInfo(this.id)">
<div class="booknoHolder" id="in"> 03& </div>
</div>
The function runs smoothly, loading book information to the element with the id more-info
as intended. However, I am facing an issue where I also want to hide or remove the booknoHolder
class when I click on the bookProp
element. I attempted to use jQuery to achieve this but haven't had any success so far. It's worth mentioning that the bookProp
elements are dynamically generated through a PHP while loop, resulting in a dynamic number of entries.