jquery/javascript content replace?how reusable
http://img163.imageshack.us/img163/6248/93306989.jpg
the images above show what i want,
i'm using Facebox to do the pop up content,so how can i make the pop up content dynamic?
<script type="text/javascript">
$(function() {
$('.openExample').click(function() {
$.facebox($('#exampleSource').val());
return false;
});
});
</script>
the code above work just fine,but how can edit to reusable???
<form>
<textarea id="exampleSource" class="expand">
<html>
<body>
<h1>Heading</h1>
<p>paragraph.</p>
</body>
</html>
</textarea>
<input type="Submit" value="Submit" class="openExample" />
<input type="reset" valu开发者_运维知识库e="Reset" />
</form>
Create a function that accepts string or id of the element.
example:
function popWindow(elementID)
{
$('.openExample').click(function() {
$.facebox($(elementID).val());
return false;
});
}
call it like this popWindow('#exampleSource');
精彩评论