Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如果类有输入值,则隐藏该类;X";_Php_Css - Fatal编程技术网

Php 如果类有输入值,则隐藏该类;X";

Php 如果类有输入值,则隐藏该类;X";,php,css,Php,Css,如何使用CSS+PHP从div表中隐藏特定于参数的卖家()?如果我访问以下网站,每个卖家都有ID: website.com/?hideseller=2 CSS代码: <div class="seller-list" id="seller-list"> <div class="head">Sellers List </div> <div class="title"> <span clas

如何使用CSS+PHP从div表中隐藏特定于参数的卖家(
)?如果我访问以下网站,每个卖家都有ID

website.com/?hideseller=2
CSS代码:

<div class="seller-list" id="seller-list">
        <div class="head">Sellers List </div>
        <div class="title">
            <span class="lable" style="width:100px">Price</span>
            <span class="lable">Seller Information</span>
            <span class="lable">Available Products</span>
            <span class="lable"></span>
        </div>
                <div class="seller">
            <form action="checkout/cart/add/uenc/aHR0cDovL3ByaWNlZ290by5jb20vYXBwbGUtaXBob25lLTVzLWdvbGQtMTZnYi11bmxvY2tlZC5odG1s/product/35720/form_key/2sprf498VYBVPIw0/" method="">
                <input type="hidden" value="1" name="seller_id">
                <span class="data" style="width:100px;">
                    <span class="price">$100.00</span>
                </span>
                <span class="data">
                    <a href="profile/TestUser" title="Visit Profile">
                        <img src="/media/avatar/noimage.png">
                        <div class="mp_landing_hover">
                            <span>TestUser</span>
                        </div>
                    </a>
                </span>
                <span class="data">10</span>
                <span class="data" style="display:none;"> Qty : <input style="width:20px;" type="text" value="1" name="qty"></span>
                <span class="data">
                <input type="submit" title="Add to Cart" class="addtocart" value="Add to Cart"></span>
            </form>
        </div>
                <div class="seller">
            <form action="aHR0cDovL3ByaWNlZ290by5jb20vYXBwbGUtaXBob25lLTVzLWdvbGQtMTZnYi11bmxvY2tlZC5odG1s/product/35720/form_key/2sprf498VYBVPIw0/" method="">
                <input type="hidden" value="2" name="seller_id">
                <span class="data" style="width:100px;">
                    <span class="price">$511.00</span>
                </span>
                <span class="data">
                    <a href="seller/profile/Test2" title="Visit Profile">
                        <img src="media/avatar/noimage.png">
                        <div class="mp_landing_hover">
                            <span>Test2</span>
                        </div>
                    </a>
                </span>
                <span class="data">1111</span>
                <span class="data" style="display:none;"> Qty : <input style="width:20px;" type="text" value="1" name="qty"></span>
                <span class="data">
                <input type="submit" title="Add to Cart" class="addtocart" value="Add to Cart"></span>
            </form>
        </div>
            </div>

卖家名单
价格
卖方信息
可用产品
$100.00
10
数量:
$511.00
1111
数量:

如果要隐藏特定的
class=“seller”
,首先需要获取
$\u get['hideseller']
id,然后使用
$.each()循环它。考虑这个例子:

<div class="seller-list" id="seller-list">
<div class="head">Sellers List </div>
<div class="title">
    <span class="lable" style="width:100px">Price</span>
    <span class="lable">Seller Information</span>
    <span class="lable">Available Products</span>
    <span class="lable"></span>
</div>
        <div class="seller">
    <form action="checkout/cart/add/uenc/aHR0cDovL3ByaWNlZ290by5jb20vYXBwbGUtaXBob25lLTVzLWdvbGQtMTZnYi11bmxvY2tlZC5odG1s/product/35720/form_key/2sprf498VYBVPIw0/" method="">
        <input type="hidden" value="1" name="seller_id">
        <span class="data" style="width:100px;">
            <span class="price">$100.00</span>
        </span>
        <span class="data">
            <a href="profile/TestUser" title="Visit Profile">
                <img src="/media/avatar/noimage.png">
                <div class="mp_landing_hover">
                    <span>TestUser</span>
                </div>
            </a>
        </span>
        <span class="data">10</span>
        <span class="data" style="display:none;"> Qty : <input style="width:20px;" type="text" value="1" name="qty"></span>
        <span class="data">
        <input type="submit" title="Add to Cart" class="addtocart" value="Add to Cart"></span>
    </form>
</div>
        <div class="seller">
    <form action="aHR0cDovL3ByaWNlZ290by5jb20vYXBwbGUtaXBob25lLTVzLWdvbGQtMTZnYi11bmxvY2tlZC5odG1s/product/35720/form_key/2sprf498VYBVPIw0/" method="">
        <input type="hidden" value="2" name="seller_id">
        <span class="data" style="width:100px;">
            <span class="price">$511.00</span>
        </span>
        <span class="data">
            <a href="seller/profile/Test2" title="Visit Profile">
                <img src="media/avatar/noimage.png">
                <div class="mp_landing_hover">
                    <span>Test2</span>
                </div>
            </a>
        </span>
        <span class="data">1111</span>
        <span class="data" style="display:none;"> Qty : <input style="width:20px;" type="text" value="1" name="qty"></span>
        <span class="data">
        <input type="submit" title="Add to Cart" class="addtocart" value="Add to Cart"></span>
    </form>
</div>
    </div>

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

    var particular_id = '<?php echo isset($_GET["hideseller"]) ? $_GET["hideseller"] : "" ?>';
    if(particular_id != '') {
        $('.seller').each(function(){
            // traverse then compare
            if($(this).children().children('input[name="seller_id"]').attr('value') == particular_id) {
                $(this).hide();
            }

        });
    }

});
</script>

卖家名单
价格
卖方信息
可用产品
$100.00
10
数量:
$511.00
1111
数量:
$(文档).ready(函数(){
变量id=“”;
如果(特定id!=''){
$('.seller')。每个(函数(){
//遍历然后比较
if($(this).children().children('input[name=“seller\u id”]')).attr('value')==特定的\u id){
$(this.hide();
}
});
}
});

如果(inputvalue是X){….}否则{….}
到目前为止,您有什么问题?您到底被困在哪里?我没有看到任何php或相关css。为什么php与此相关?@jeroen我甚至不知道如何开始,我想了一些类似
//css
的东西,但我不确定这是否是一个好方法,而且如果用户访问其他网站,我希望它是持久的product@j08691javescript更合适吗?我选择PHP仅仅是因为get变量是我想正确过滤我想要的东西的方式,我已经添加了代码,它确实可以获得
特定的\u id
,但它不会隐藏,我在footer?@zumbamusic中包含了这个,我在工作状态下编辑了答案,记住只需更改jquery路径,我已经包含了
jquery-1.8.3.min.js
include,我认为它应该可以工作,但它只有在谷歌包含
jquery.min.js
之后才起作用,谢谢你的代码!如果我想在用户重定向到其他页面/产品后使此持久化,我应该考虑保持$\u GET变量的持久性,或者更好的主意是使用cookie?@zumbamusic欢迎您,是的,或者,如果它是持久的,你可以把它放在cookie中。现在看来,如果我包含来自谷歌的jquery,我对jquery有一个问题。这个脚本工作正常,但网站的其他功能没有,如果我包括jquery-1.8.3.min.js,所有功能都可以使用,但这个脚本有点丢失,这是什么?我试着只调用1,但两者都不奇怪,有什么想法吗?