Consider following HTML snippet:

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

$('.link').click(function(e){
    e.preventDefault();
    $(this).hide().clone(false).insertAfter(this).show();
}).click();
Explanation
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 www.quizful.com page. And finally we have added a click() method at the end of our script inside the function that will click on the link.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести