Toggle Show Hide-0Javascript
Discuss coding issues, and scripts related to PHP and MySQL.
-
JanMolendijk
- Posts: 267
- Location: Holland Rotterdam
Toggle Show Hide-0Javascript
Hello CoursesWeb,
I have sql document with 4 results from-out database.
But I can`t open the results from the post_id ????
What do I do wrong ?
Code: Select all
<script>
$(document).ready(function() {
// when click on the tag with id="btn"
$('#btn11'.$row['post_id'].'').click(function() {
// change the state of the "#idd"
$('#idd11'.$row['post_id'].'').toggle(800, function() {
// change the button text according to the state of the "#idd"
if ($('#idd11'.$row['post_id'].'').is(':visible')) {
$('#btn11$row['post_id']').text('Hide');
} else {
$('#btn11'.$row['post_id'].'').text('Show');
}
});
});
});
</script>
Code: Select all
<div id="idd11'.$row['post_id'].'" style="display:none;">
<?php echo $row['post_text'] ?>
</div>
<button id="btn11'.$row['post_id'].'">Hide</button>
MarPlo
Try the following code. See the differences.
Code: Select all
<?php
echo '<div id="idd11'. $row['post_id'] .'" style="display:none;">';
echo $row['post_text'];
echo '</div>
<button id="btn11'. $row['post_id'] .'">Hide</button>';
?>
<script>
var post_id_php = <?php echo $row['post_id']; ?>;
$(document).ready(function() {
// when click on the tag with id="btn"
$('#btn11'+ post_id_php).click(function() {
// change the state of the "#idd"
$('#idd11'+ post_id_php).toggle(800, function() {
// change the button text according to the state of the "#idd"
if ($('#idd11'+ post_id_php).is(':visible')) {
$('#btn11'+ post_id_php).text('Hide');
} else {
$('#btn11'+ post_id_php).text('Show');
}
});
});
});
</script>
Similar Topics
-
Hide element if data contains specific text
HTML - CSS
First post
Is there a possibility to hide HTML elements if the 'data-' attribute contains a specific piece of text?
For example: Hide the Divs that it's data...
Last post
You can do this with either CSS or Javascript.
CSS:
/* with specified elements */
div {
display: none;
}
/* or global */
{
display: none;...
-
Show with animation the content added with JavaScript
JavaScript - jQuery - Ajax
First post
The idea is that when i click on a button, old content gets replaced by new HTML content added with javascript.
I want that new content to appear...
Last post
To trigger a CSS transition, change the CSS state after you inserted the HTML. You can do this by changing a class (on the container or an inserted...
-
Hilarious photos show squirrels lifting nutty barbells
Entertainment and Games
Swoll squirrels in Sweden displayed their strength by hoisting nut barbells that an inventive photographer left in his backyard for them.
<div...
-
imgbrowse CKEditor files upload, don't show up in imgbrowse
Scripts from this website
First post
I've downloaded the CKEditor with Free Image Browse and Upload Plugins (version 4.5.3) package, from:...
Last post
It is correct to display Root.
I tested again the plugins for Upload image, and the Imgbrowse. In my tests on localhost (with windows 10) it works....