admin管理员组

文章数量:1416631

I'm using a ThickBox on a client's site to display a modal form. It's working well, except I can't get it to close. I'm sending modal=true so the title doesn't display, but I'm using divs as buttons to save information or close the box. From the examples I've seen I should be able to just call tb_remove() and that should take care of it, but it's not working at all.

<div style="clear: both;">
        <div class="buttons" onclick="javascript:tb_remove()">
            <h2>Cancel</h2>
        </div>
        <div class="buttons">
            <h2>Save</h2>
        </div>
    </div>

I'm using a ThickBox on a client's site to display a modal form. It's working well, except I can't get it to close. I'm sending modal=true so the title doesn't display, but I'm using divs as buttons to save information or close the box. From the examples I've seen I should be able to just call tb_remove() and that should take care of it, but it's not working at all.

<div style="clear: both;">
        <div class="buttons" onclick="javascript:tb_remove()">
            <h2>Cancel</h2>
        </div>
        <div class="buttons">
            <h2>Save</h2>
        </div>
    </div>
Share Improve this question asked Feb 6, 2012 at 18:43 CarlCarl 1,2763 gold badges23 silver badges41 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Are you getting any javascript errors? Check the console. Also, I would much rather write it like this:

HTML

<div id="wrap">
    <div class="buttons">
        <h2>Cancel</h2>
    </div>
    <div class="buttons">
        <h2>Save</h2>
    </div>
</div>

JAVASCRIPT

$(function() {
    $('.buttons').click(function() {
        tb_remove();
    });
});

CSS

#wrap {clear:both;}

本文标签: javascriptClosing ThickBox Modal WindowStack Overflow