开发者

Calling a jQuery Dialog without a DIV

开发者 https://www.devze.com 2023-01-14 08:44 出处:网络
Is it possible to create a popup without being based on a div. Example, I have a the fo开发者_C百科llowing DIV:

Is it possible to create a popup without being based on a div. Example, I have a the fo开发者_C百科llowing DIV:

<div id="dialog" title="Info">
    <p>This is a test</p>
</div>

Instead of calling a dialog like this:

$("#dialog").dialog();

I would like to call like this:

 $("This is a test").dialog();

How would it be possible?

Thank you, Regards.


You can call it like this:

 $("<div>This is a test</div>").dialog();


To test for a string and, if found, do something (replace the hover function alert("Found"); with whatever you want to do):

<script type="text/javascript">
$(function(){
    if ($("#dialog p").text("This is a test")) {
        $("#dialog p").hover(function() {
            alert("Found");
        });
    }
});
</script>
0

精彩评论

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