Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove specified text from a variable using JQuery

Tags:

jquery

text

I have a variable named position where I want to remove some of its text. The exact text I want to remove is contained within the variable title.

var title = $(currentLi).find('img').attr('alt');

var position = $(currentLi).find('span').text();

So just to clarify, I am creating a variable named position which contained text, I want to remove all the text that matches the text within the variable title.

Thanks for anyones help.

like image 613
Cecil Theodore Avatar asked Dec 27 '22 08:12

Cecil Theodore


1 Answers

position = position.replace(title, "");

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace

like image 172
karim79 Avatar answered Jan 11 '23 17:01

karim79