我使用$.noConflict()
在同一页面上使用两个版本的jquery。但是较旧的代码无效。
<!-- load old jquery, add no conflict immediately after that -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$.noConflict(true);
</script>
<!-- place where new jquery is loaded, add noconflict for the same -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
var j1124 = $.noConflict(true);
</script>
<script>
//for new jquery
j1124(document).ready(function() {
j1124("#TxtBox").on("click", function() {
console.log("on");
});
});
$(document).ready(function() {
//for old jaquery
$("#TxtBox1").live("click", function() {
console.log("live")
});
});
</script>
<h3>Page with issue. Old and new jqueries in use. Live not working</h3>
<div>
<input name="TxtBox" type="text" id="TxtBox" />
<input name="TextBox1" type="text" id="TextBox1" />
</div>
&#13;
我的直播功能不起作用。请帮忙