Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select all SPAN elements which contain a "foobar" property? If possible with jQuery #2014

Open
pstein opened this issue Mar 25, 2024 · 6 comments

Comments

@pstein
Copy link

pstein commented Mar 25, 2024

How can I select (from Tampermonkey script) all SPAN elements in current webpage which contain a property "foobar"?

The assigned value is unimportant.

So elements like the following should be matched:

<span aaa="bbb" foobar="23452345" .....>...</span>

I tried:

$('span[foobar^=""]').remove();

but it didn't work.

And

$('span').attr('foobar').remove();

didn't work either.

@7nik
Copy link

7nik commented Mar 25, 2024

To use $ (jQuery), you need to add it to the userscript:

// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js

or use document.querySelectorAll().

@pstein
Copy link
Author

pstein commented Mar 25, 2024

Yes, I already added:

// @require http://code.jquery.com/jquery-latest.js

So this is not the problem/solution

@7nik
Copy link

7nik commented Mar 25, 2024

* jQuery JavaScript Library v1.11.1
* Date: 2014-05-01T17:42Z

It's more ancient than mammoths.

@7nik
Copy link

7nik commented Mar 25, 2024

// @require http://code.jquery.com/jquery-latest.js

It seems to work. Can you provide an entire minimal userscript where it doesn't work?

@pstein
Copy link
Author

pstein commented Mar 25, 2024

Hmm, interesting.

However your suggested cloudflare URL contains a version number ("v3.2.1")
Is there a version number independent cloudflare URL which redirects to always the latest jQuery library (similar to my URL)?

@7nik
Copy link

7nik commented Mar 25, 2024

here you can choose a link with a loose version https://www.jsdelivr.com/package/npm/jquery

but it seems something is wrong with your environment and jQuery cannot define $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants