如何在没有内容的情况下删除/隐藏<div> </div>标签?

时间:2012-04-01 04:35:09

标签: html ajax

例如我有:

<div id ="test">[the content here]</div>

在使用ajax调用div的id后,div标签内的内容将出现。 这是代码:

function dinamic(add)
{
    var kode = add.value;
    if (!kode) return;
    xmlhttp2.open('get', '../template/get_id.php?kode='+kode, true);
    xmlhttp2.onreadystatechange = function() {
        if ((xmlhttp2.readyState == 4) && (xmlhttp2.status == 200))
        {
            var add = document.getElementById("test");
                add.innerHTML = xmlhttp2.responseText;
        }
        return false;
    }
    xmlhttp2.send(null);
}

因此会出现<div id="test">A</div>

我想把div的内容 - &gt;进入mysql查询。

$test = $_GET['test'];
$query = "select * from example where category='$test'";

我尝试使用div id的变量$test来获取内容,但类别中的查询结果为none。 我再次尝试,我将div放入查询

$query = "select * from example where category='<div id=\"test\">A</div>'";

是的,它有效。但是当我对navicat进行查询时,我没有得到任何结果,因为A之间有<div></div>之间的空格。 如何仅删除/隐藏div标签,使其仅显示内容?

> $query = "select * from example where category='A'"; <

修改 如果我在firefox浏览器上回显查询会说"$query = "select * from example where category='[space]A[space]'";" 看看这个bug(我使用的是firebug),它会说"$query = "select * from example where category='<div id="test">A</div>'";"

所以我猜测为什么在navicat上查询后无法得到结果 A ([space] A [space])之间有空格,只是不知道如何删除/隐藏div标签,我想仅获得此结果"$query = "select * from example where category='A'";"


感谢。

0 个答案:

没有答案
相关问题