Using the Johann Burkard inc: A super-tiny client-side include JavaScript jQuery plugin with onclick works but I have not been unable to change it into an href with direct Javascript code:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src=""></script>
<p onclick="$(this).inc('inc_me.html');">1) Paragraph with onclick</p>
<a href="javascript:$(this).inc('inc_me.html');">2) Href with javascript</a>

What I Did and What It Did:

When clicking on the first paragraph its content is replaced by the contents of inc_me.html. When clicking on the second paragraph nothing changes.

What I Expected:

I expected the second paragraph to be replaced in the same way that the first one was.

What is the jQuery way to get this passed to $()?

I am using Google Chrome 5.0.307.11 beta.

2 answers

<p id="p2"></p><a id="a2" href="javascript:$('#p2').inc('inc_me.html');$('#a2').empty();">2) Href with javascript</a>
Answered about 9 years ago by C.W.Holeman II
Mottie 1134

I didn't do a lot of digging into the code, but I think to make it work with the code in the href you may have to change the plugin.

There are two other ways to call the script though that will work:

<a href="#" onclick="$(this).inc('inc_me.html');return false;">Href with javascript</a><br>


<a class="p2" href="#">Href with javascript</a>
<script type="text/javascript">
  return false;
Answered about 9 years ago by Mottie