小编Bis*_*ura的帖子

单击按钮时删除 div

我正在尝试删除div按钮单击,但问题是我需要按钮来删除它包含的 div,而不将 div 的 id 传递给删除按钮

所以最后的这段代码应该能够删除 div 而无需传递 div 的 id,而是依赖于传递this引用

<!doctype html>
<html>

<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
        $(document).ready(function() {
            $(document).on('mouseenter', '#divbutton', function() {
                $(this).find(":button").show();
            }).on('mouseleave', '#divbutton', function() {
                $(this).find(":button").hide();
            });
        });
    </script>

    <style>
        #divbutton {
            height: 100px;
            background: #0000ff;
        }

        #divbutton2 {
            height: 100px;
            background: #0000ff;
        }

        #divbutton3 {
            height: 100px;
            background: #0000ff;
        }
    </style>
</head>
<body>
    <div id="divbutton">
        <button type="button" style="display: none;" id="i" onclick="document.body.removeChild(document.getElementById('divbutton'))">Hello</button>
    </div>

    <div id="divbutton2">
        <button type="button" style="display: none;" id="i" onclick="document.body.removeChild(document.getElementById('divbutton2'))">Hello …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

5
推荐指数
1
解决办法
2万
查看次数

如何在html按钮上执行php函数点击

您好我想bb()按钮点击执行功能.
我尝试了下面的代码,但它没有用.

echo "<div class ='i2' id=".$x.">";
echo "<button type='button' style='display: none;' id='i' name='delete' onclick='document.body.removeChild(this.parentNode)'>";
echo"</button>";
echo "</div>";

<?php

function bb()
{
 echo "hello";
}
if (isset($_GET['delete'])) {
 bb();
}

?>
Run Code Online (Sandbox Code Playgroud)

html php

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

html ×2

javascript ×1

jquery ×1

php ×1