Skip to main content

Bug Tracker

Side navigation

Ticket #4684: jquery_opera_live_bug.html
File jquery_opera_live_bug.html, 1.4 KB (added by alex_sh, May 21, 2009 07:45PM UTC)

HTML test case

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
		<meta content="text/javascript; charset=utf-8" http-equiv="Content-Script-Type">
		<meta content="text/css; charset=utf-8" http-equiv="Content-Style-Type">
		<title>JQuery live() test</title>

		<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
	</head>
	<body>

	<script type="text/javascript">
		<!--//--><![CDATA[//><!--

		$(document).ready(function() {

			$("#load_button").click(function() {
// 				var div = document.getElementById("contents_div");

				// remove contents
// 				while(div.firstChild) {
// 					div.removeChild(div.firstChild);
// 				}

				// create a new button and add it to the div
// 				var button = document.createElementNS("http://www.w3.org/1999/xhtml", "input");
// 				$(button).attr("type", "button").attr("value", "New button");

// 				div.appendChild(button);

				$("#contents_div").html('<input type="button" value="New button" />');

			});


			$("#contents_div > input").live("click", function() {
				alert("Clicked");
			});

		});

		//--><!]]>
	</script>

	<form id="f_form" action="#">
		<div>

			<input type="button" id="load_button" value="Load new contents"><br><br>

			<div id="contents_div">
				<input type="button" value="Old button">
			</div>

		</div>
	</form>

	</body>
</html>

Download in other formats:

Original Format