Reputation: 1135
So I'm trying to load a page that is in same folder as my main page, and it doesn't load on click. Maybe something is wrong with my code. I know that it is called because I checked it with alert.
Code bellow.
<script>
function closeIt() {
e.preventDefault();
$("#load-here").load($(this).attr('secound.html'));
};
</script>
<div id="buttons" >
<form>
<button class="btn" onClick="closeIt()" >secound</button>
</form>
</div>
<div id="load-here">
hehehe
</div>
Upvotes: 0
Views: 84
Reputation: 10101
There are a couple of problems here. First, your function closeIt
is not a jQuery event handler, so e
hasn't been defined and you can't call preventDefault()
on it. Secondly, you are misusing attr
, which is used to get an attribute from a DOM element. Replace the function definition of closeIt
with the following:
function closeIt() {
$("#load-here").load('secound.html');
}
Upvotes: 2