+1 vote
by
<div class="product-layout-1">
<div class="product-thumb transition">
<div class="image">
<a href="http://m.me/">
</a>
</div>
<div class="caption">
<a href="http://m.me/" style="height: 44px;">Chat</a>
</div>
<div class="cart">
<button>В корзину</button>
</div>
</div>
</div>
$('[href*="path=94"]').attr('href', 'http://m.me/')
There are several such html blocks, where if the link has path=94, I change the attribute to m.me How do I change the .cart block only where the link changes? Tried it, but it changes everywhere there is a .cart block
if ($(".product-thumb a").attr("href", "http://m.me/")) {			        
$('.cart').append('<div>111111111111</div>')
}

2 Answers

0 votes
by
 
Best answer
$('[href*="path=94"]').each(function() {
$(this)
.attr('href', 'http://m.me/')
.closest('product-thumb').find('.cart').append('<div>111111111111</div>')
})
0 votes
by
Pure js: .innerHTML='текст';
Jquery: .text='текст';

Or use parentheses instead of "=":('текст')
by
I have a problem that it finds a block with a link m.me/, But it adds a block of html at the end of everything. And you need only where the link changes in the product-thumb a
by
Code-NaN , read first through the.attr('href') without setting a value. And then update it.
...