开发者

jquery/javascript content replace?how reusable

开发者 https://www.devze.com 2022-12-18 09:16 出处:网络
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?

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');

0

精彩评论

暂无评论...
验证码 换一张
取 消