не работает усдовие?
Не могу понять в чем тутдело
<p class="icon_list_soc"><a class="product-statistic-soc__item" href="/product.php?pid=32"><i class="icon-p-ok active"></i></a><a class="product-statistic-soc__item" href="/product.php?pid=72"><i class="icon-p-ok active"></i></a></p> $(function() { var href = $(".product-statistic-soc__item").attr('href'); //alert(href); if ( 'href' === '/product.php?pid=32') { alert('Условие работает'); $(this).css({ "display":"none"}); } }); |
Cdelphi78,
а разве строка href равна строке /product.php?pid=32 ? |
destus,
Спасибо, неравна? сейчас проверю |
Вроде правильно написал, что вы имеете ввиду?
|
Цитата:
|
Я смотрел эту статью не очень понятно по ней.
Вроде заработало, убрал апостолы прописал кавычки, однако теперь не работает this почему то? |
Cdelphi78,
В данном случае $(this) ссылается на document, а его скрывать нельзя. <script> $(function () { $(".product-statistic-soc__item").attr('href') === '/product.php?pid=32' && $(".product-statistic-soc__item").css({ "display": "none" }); }); </script> <p class="icon_list_soc"><a class="product-statistic-soc__item" href="/product.php?pid=32"><i class="icon-p-ok active"></i></a><a class="product-statistic-soc__item" href="/product.php?pid=72"><i class="icon-p-ok active"></i>123</a></p> |
щас условие не работает он не выбирает элемент с pid=32 и скрывает оба
|
Cdelphi78,
<script> $(function () { $(".product-statistic-soc__item").each(function () { $(this).attr('href') === '/product.php?pid=32' && $(this).css({ "display": "none" }); }) }); </script> <p class="icon_list_soc"><a class="product-statistic-soc__item" href="/product.php?pid=32"><i class="icon-p-ok active"></i>222</a><a class="product-statistic-soc__item" href="/product.php?pid=72"><i class="icon-p-ok active"></i>123</a></p> |
Destus, заработало, большое спасибо, без вас бы не справился)
|
Часовой пояс GMT +3, время: 02:07. |