How to select an element that has an ID which begins with a digit?
You can access it by using an attribute selector and selecting the ID attribute:
[id='634670717473476800'] {
background-color: red;
}
<div id="634670717473476800" align="center" style="width: 100%; overflow-y: hidden;" class="wcustomhtml">div</div>
How to select css id's with numbers in them?
What about using the following selector:
input[id^='something_stuff_'][id$='_work']
It will get inputs with id starting with "something_stuff_" and finishing with "_work".
Find all elements whose id begins with a common string
Using jQuery you can use the attr starts with selector:
var dates = $('[id^="createdOnid"]');
Using modern browsers, you can use the CSS3 attribute value begins with selector along with querySelectorAll
:
var dates = document.querySelectorAll('*[id^="createdOnID"]');
But for a fallback for old browsers (and without jQuery) you'll need:
var dateRE = /^createdOnid/;
var dates=[],els=document.getElementsByTagName('*');
for (var i=els.length;i--;) if (dateRE.test(els[i].id)) dates.push(els[i]);
jQuery selector for id starts with specific text
Use jquery starts with attribute selector
$('[id^=editDialog]')
Alternative solution - 1 (highly recommended)
A cleaner solution is to add a common class to each of the divs & use
$('.commonClass')
.
But you can use the first one if html markup is not in your hands & cannot change it for some reason.
Alternative solution - 2 (not recommended if n is a large number
)
(as per @Mihai Stancu's suggestion)
$('#editDialog-0, #editDialog-1, #editDialog-2,...,#editDialog-n')
Note: If there are 2 or 3 selectors and if the list doesn't change, this is probably a viable solution but it is not extensible because we have to update the selectors when there is a new ID in town.
How to select HTML element by id that is a number in beatiful soup
You can use div[id="27047243"]
:
from bs4 import BeautifulSoup
html_doc = """
<div id=27047243>
I want this.
</div>
"""
soup = BeautifulSoup(html_doc, "html.parser")
print(soup.select_one('div[id="27047243"]'))
Prints:
<div id="27047243">
I want this.
</div>
what if element's ID begin with a number
The standard specifies that IDs must start with a letter. If browsers (or rather JavaScript engines) choose to ignore that requirement, then that's just the way it is. Browsers are really forgiving that way ...
How to select all elements whose ID starts and ends with specific strings?
The following CSS3 selector will do the job:
tr[id^="section_"][id$="_dummy"] {
height: 200px;
}
The ^
denotes what the id
should begin with.
The $
denotes what the id
should end with.
id
itself can be replaced with another attribute, such as href
, when applied to (for example) <a>
:
a[href^="http://www.example.com/product_"][href$="/about"] {
background-color: red;
}
jQuery selector help - how to find element whose ID starts and ends with specific characters
Well, you were almost there...$('[id^=cc-][id$=1]')
DEMO:http://jsfiddle.net/pavloschris/nr3ad/
Related Topics
Html5 Placeholder Disappears on Focus
Selectable <Optgroup> in HTML <Select> Tag
How to Make Select Elements Shrink to Max-Width Percent Style Within Fieldset
How to Display Text, a Dotted Line Then More Text Spanning the Width of the Page
When I Try to Shift the Image Upwards Using Negative Margin the Whole Container Is Moved Upwards
Google Maps Shows "For Development Purposes Only"
Flexbox Layout Does Not Work in Internet Explorer 10
Why Does Negative Z-Index and Non-Static Position Disable My Checkbox in Most Browsers
Header/Footer Layout with 100% Content Height in IE8
Using Os 9 Resource Fork Fonts in CSS with @Font-Face
How to Ellipse a Clipping Mask on the Bottom Only
Why Alignment Mark List Is Different on Webkit When Using :Before Height