WKWebView iOS.
js- WKWebView Delegate.
:
$('body').on('click', '#div', function(){})
:
$('#div').click(function(event) {});
==========================================
:
1:
<html>
<body>
<div class="test"></div>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="test3.js"></script>
</body>
$(document).ready(function(){
$('button').click(function() {
console.log("It worked");
});
$('.test').html('<button>Test</button>');
});
Here we attach the .click method to a button, but if you look at html, the button does not exist yet, so we bind the .click method to a nonexistent element. The button element will be added to the .test class, but it will not be bound to this .click method. Therefore, if you loaded this page and tried to click the test button, it did nothing.
Method 2:
<html>
<body>
<div class="test"></div>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="test3.js"></script>
</body>
$(document).ready(function(){
$('body').on('click', 'button', function() {
console.log("It worked");
});
$('.test').html('<button>Test</button>');
});
This will exit the “It worked” system.
source
share