need to do so that in the basket when adding an order, the text "place order" was a link leading to the page for example basket.php.

$(document).ready(function() { $('.header__menu a i').click(function() { $('.sub-menu').toggle() }) //тут кол-во товара $('.add-tovar').click(function() { var count = parseInt($("#tovar").text()) + 1; $("#tovar").text(count); if (count > 0) { $("#kol").text("оформить заказ"); } }); //тут должна прибавляться цена товара $('.add-tovar').click(function() { // Get total var total = $('#cena').attr('data-total-price') // Set total converting it to number total = +$(".cost", this).attr('data-price') + (+total) $('#cena').attr('data-total-price', total) //---------------------------------------------------------------- // Set price veiw $("#cena").text('$' + total); }) }) 

    1 answer 1

    The easiest way, if I understand you correctly, then add not a text but a tag with text - instead of .text () use .html ()

     $("#kol").html('<a href="/basket.php">оформить заказ</a>'); 

    There is an option to change the tag itself

     $("#kol").replaceWith(function(index, oldHTML){ return $('<a href="/basket.php">').html(oldHTML); }); 

    * Moreover, I didn’t quite understand your logic - in count you will have either NaN or a number - at least 1. And below you check it with count> 0.

    • The logic is simple, the default is in my html "cart is empty", so I set the condition if count is more than 0 then the code is executed (the inscription "cart is empty" changes to "place order") // now my caption changes to text "place an order" and you need to link to "place an order." - ilyaaa521
    • Well, how to change the link I showed. But at the expense of logic - when you click on add-tovar: count = parseInt ($ ("# tovar"). Text ()) + 1; Those. in any case, you count will have at least 1! After one line, put the check if (count> 0) - Yuri Kopot
    • Thank you very much, I helped out - ilyaaa521