I want to "play" with jQuery's hide()
function on a blog that I have and I want to make it so that clicking a button will hide all "cake names" on my page. I don't really know how to do that because I'm a beginner in jQuery. Can somebody help me, please? My code is:
<?php @include APP_PATH . '/view/snippets/header.tpl.php'; ?>
<h2>Our cakes</h2>
<script>
$(document).ready(function(){
$("button").click(function(){
$("h2").hide();
});
});
</script>
<?php if ($cakes) : ?>
<ol>
<?php foreach ($cakes as $cake) : ?>
<li>
<h3><?php echo $cake->name; ?></h3>
<ul>
<li><b>Quantity:</b> <?php echo $cake->quantity ?></li>
<li><a href="<?php echo APP_URL ?>cake/view/<?php echo $cake->id ?>">View</a></li>
</ul>
</li>
<?php endforeach; ?>
</ol>
<body>
<button>Click me</button>
</body>
<?php else : ?>
<p>Sorry, no sugar for you, babyyy!!</p>
<?php endif; ?>
<?php @include APP_PATH . '/view/snippets/footer.tpl.php'; ?>
I tried something but it doesn't work.
before tag. It's not looks good. When you ask your question here, please, write in standard way.. :) One down vote for wrong html code -1
– Nono May 23 '13 at 08:53