0

Hello I am using a slider that generates a button and gives it some text. I am wondering if there is some way to remove this text using jQuery. I am not able to edit the html because it is being generated by the slider.

Here is my HTML:

<button type="button" class="slick-next">Next</button>

As you can see it is giving the button a text of "Next" I would like to completely remove it so it looks like:

<button type="button" class="slick-next"></button>

Is this possible?

Thanks

2
  • 7
    $(".slick-next").text(""); Commented Sep 13, 2016 at 21:22
  • thanks andrew, that worked perfectly. could you post it as an answer so I can give you some reputation? Commented Sep 13, 2016 at 21:27

1 Answer 1

5

As Andrew commented, using jQuery you can replate existing text with empty text:

$(".slick-next").text("");
//or
$(".slick-next").html("");

Also using Vanilla Javascript, you can achieve the same effect:

document.querySelector('.slick-next').innerHTML = "";
//or
document.querySelector('.slick-next').innerText = "";

The last solution is the best at my opinion, because you completely get rid of unnecessary text node inside the element:

// vanilla js
var element = document.querySelector('.slick-next');
element.removeChild(element.childNodes[0]);

// jQuery version
$(".slick-next").empty();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.