Consider following HTML snippet:

<a class="link" href="">quizful</a>
What will be the result of executing following jquery code?

For the link we have assigned a function on click that will do the following: e.preventDefault(); - cancel the default event (go to the link); $(this).hide(); - hide the link on page; .clone (false) - clone the link without event inheritance; .insertAfter(this) - insert the cloned link after the link; .show(); - display cloned link on the page; It means: we hide the link, then cloned it and inserted after our hidden link. Next we make our cloned link visible. When cloning we canceled the preventDefault() event and so when we will click on the link we will move to the page. And finally we have added a click() method at the end of our script inside the function that will click on the link.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes