Hello,
when I click on "Click Here" then a page must open inside
<script....>
$('yahoo').html('<a href=desc.php>');
</script>
<div id='yahoo'></div>
<div id='clickhere'>Click here</div>
Thanks Dave
Hello,
when I click on "Click Here" then a page must open inside
<script....>
$('yahoo').html('<a href=desc.php>');
</script>
<div id='yahoo'></div>
<div id='clickhere'>Click here</div>
Thanks Dave
I think you're looking for AJAX to fetch the page for you. Something like this might work:
<script type="text/javascript">
$(function() {
$('#clickhere').click(function() {
$('#yahoo').load('desc.php');
});
});
</script>
<div id='yahoo'></div>
<div id='clickhere'>Click here</div>
First you need to wrap the script inside $(function() { ... })
to execute your code on page load. This is equivalent to $(document).ready(function() { ... })
.
Next you have to bind a click event to the #clickhere
element so you can actually do something when the user clicks on it.
When the user clicks on the #clickhere
div, load() will fetch the contents of the given url inside the element you call it from. So, this snippet means that when the #clickhere
div is clicked, desc.php
is loaded inside #yahoo
div.
Wrap your code in $(document).ready(function() { });
, which will insure that the code executes after the DOM is available to your code. Otherwise, $('yahoo')
will likely return no matched elements.
#ID
, not just ID
desc.php
pageDOMContentLoaded
eventWhy not try target_self ? I also fixed some code
<script....>
$('yahoo').html('<a href=desc.php target='>self'>Click here</a>');
</script>
<div id='yahoo'></div>
<div id='clickhere'>Click here</div>