0

I am having a problem using multiple jQuery commands.

My code:

$('td[background="/images/PBox_Border_Left.gif"]').remove();
$('td[background="/images/PBox_Border_Bottom.gif"]').remove();
$('td[background="/images/PBox_Border_Right.gif"]').remove();

How do i separate these so they all work? Thanks.

1
  • If they all work individually, they should all work together like that. Commented Dec 10, 2011 at 23:59

3 Answers 3

3

Just seperate rules with comma.

$('td[background="/images/PBox_Border_Left.gif"], td[background="/images/PBox_Border_Bottom.gif"], td[background="/images/PBox_Border_Right.gif"]').remove();

I suggest you should use them with combined version, it will work more faster than working the same method line by line.

Sign up to request clarification or add additional context in comments.

Comments

3

You can use multiple selectors if you separate them by commas (all in the same string):

$('td[background="/images/PBox_Border_Left.gif"], td[background="/images/PBox_Border_Bottom.gif"], td[background="/images/PBox_Border_Right.gif"]').remove();

Docs: http://api.jquery.com/multiple-selector/

There is also the .add() function:

$('td[background="/images/PBox_Border_Left.gif"]').add('td[background="/images/PBox_Border_Bottom.gif"]').add('td[background="/images/PBox_Border_Right.gif"]').remove();

Docs: http://api.jquery.com/add

Comments

2

If you want to search for all td with backgrounds that start with "/images/PBox_Border_" you can do this:

$('td[background^="/images/PBox_Border_"]').remove();

You could also check to make sure it's a gif as well:

$('td[background^="/images/PBox_Border_"]')
   .filter('td[background$=".gif"]')
   .remove();

I just had to use a search like that, so just in case you need the info.

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.