$(document).ready(function(){
$(document).on('click','.opys',function(e){
e.preventDefault();
var link = $(this).attr("href");
$('#target').load(link);
});
});
<div id="target">
</div>
Как реализовать код, чтобы можно было выполнять скрипты в загруженном блоке, например, слайдшоу? Все скрипты содержатся в main.js, также еще подключена сама библиотека jquery в основном документе.
We have to strip the scripts out otherwise they may be executed many times. The case where a user inserts a list item (for example) with a script inside of it that pertains to that particular item. The user then, later, clones that list item (or moves the list item to a different part of the tree) results in the scirpt being re-executed if we haven't removed it ahead of time.
In short: No browser does "run scripts on injection" so we're kind of defining our own semantics here - one aspect of that being that in order to avoid having scripts run way too many times we strip them out of the source.