Hi

I have a photo gallery... I was wondering if its possible using DOM scripting, to dynamically add a div around an existing image, making the new div the image's parent?!

Thanks

try:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>hielo</title>
		<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
		<script type="text/javascript">
		$(function(){
			var img=$('img[src$=toolbar_favforums.gif]');
			var div = $('<div style="border:1px solid black;"></div>').insertAfter(img);
			$( $(img).remove() ).appendTo(div);
			
		});
		</script>
	</head>
	<body>
		<img src="http://www.daniweb.com/rxrimages/toolbar_favforums.gif" alt="" onclick="alert(1)">
	</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.