selectors-api

How to set rounded buttons with background color and change color on pressed

旧城冷巷雨未停 提交于 2019-12-04 16:34:43
In my android app there is a rounded rectangle button with green colored background. i did this using .xml file <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:padding="10dp" android:shape="rectangle" > <solid android:color="#B5D397" /> <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" /> </shape> and android:background="@drawable/rounded_btn" in layout file but when i press button is wasn't showing any effect(no change is color) so i used

querySelectorAll not working

╄→гoц情女王★ 提交于 2019-12-04 05:05:05
I have a requirement where I have to pickup the last .div within a container and apply some business logic to it. The selection of the last .div has to be dynamic because the user has the option to add/remove .div elements. Initially I tried with querySelectorAll but it did not seem to work. So I decided to change it to getElementsByClassName and surprisingly it worked with the same logic. Can somebody please help me with the reason for why the remove_div doesn't work while the second one ( remove_div_2 ) does? Note: I am not looking for a fix/solution to the issue because I have already

Getting selected options with querySelectorAll

馋奶兔 提交于 2019-12-03 22:18:33
I wonder if it's possible in Javascript to get the currently selected options in a <select multiple> field using the Selctors API rather than a "stupid" iteration over all options. select.querySelectorAll('option[selected="selected"]') only returns the options that were marked as preselected in the original HTML, which is not what I'm looking for. Any ideas? document.querySelectorAll('option:checked') Works even on IE9 ;) I was also experienced your issue, I have a feeling it's to do with JavaScript not recognising changes in the DOM. Here is a solution: jsFiddle document.getElementById('test'

How do I test CSS selectors in JavaScript?

▼魔方 西西 提交于 2019-12-03 15:44:10
How could I test CSS1-3 selectors to check that they get the correct elements, e.g. with JavaScript (maybe jQuery)? BoltClock The simplest traditional way by far is to not use JavaScript at all, and just set up a test page by hand where you can test selectors to your heart's content. The test cases you see on the Web (like the well-known CSS3.info Selectors Test ) are really just souped-up versions hosted online. But if you're looking for a JavaScript method, you can try the Selectors API . It's available in modern DOM implementations (IE8+ and others) and it provides a JavaScript frontend for

Is it possible to make querySelectorAll live like getElementsByTagName?

冷暖自知 提交于 2019-12-03 12:37:15
getElementsByTagName() has 2 great features: it is fast and it is live. But what if I want to get p strong . Of course I could refine a selection using getElementsByTagName() again but wouldn't I lose the live effect for the new p tags? Is there a way to turn querySelectorAll into a live selector? Or... is there a way to use getElementsByTagName() and getElementsByClassName() to create a function that works in a similar way (at least with descendants) as querySelectorAll but being live? Consider using mutation observers. Watch for childList with subtree: true . When the notification arrives,

Can I put logical operators in document.querySelectorAll? If so, how?

随声附和 提交于 2019-12-03 12:07:44
Let's say I want to find all div elements and span inside p . Is it possible to get all what I want in a single `querySelectorAll" invocation? Conceptually it should be something like document.querySelectorAll("div | p span") (if | means or ). Yes. You can use the same logical operators allowed in CSS: OR: chain selectors with commas document.querySelectorAll('div, p span'); // selects divs, and spans in ps AND: chain selectors without whitespace document.querySelectorAll('div.myClass'); // selects divs with the class "myClass" NOT: :not() -selector document.querySelectorAll('div:not(.myClass)

Is querySelector supported by all browsers?

一曲冷凌霜 提交于 2019-12-03 10:37:17
I would like to know is querySelector supported by all browsers? is not what's alternate for it to use? I have tested it with IE8, FF3, Chrome 4. Its fine for me. I do not have old browsers. So i would like to know if old browsers will give problem to me or not? IE7< don't support it and IIRC IE8 has issues with namespaces. There's at least one more esoteric browser out there with major issues but I don't recall which it is. Basically there is no unified expression-based DOM method, and absolutely your best bet is to use a library (the ubiquitous "use jquery" answer, but you should at least

document.querySelectorAll get innerText of ALL selected elements at once pure javascript

♀尐吖头ヾ 提交于 2019-12-03 08:35:51
I want to get all innerText of a whole column of a very long html table (random length). I'm using this code: var tbEls = document.querySelectorAll('#tBodyID tr td:nth-child(cidx)'); Where cidx = the column index I want to extract content from. But such code extracts all the td elements (with the innerText inside them of course). But it doesn't extract directly all the innerText inside them. Cause of this I have to reprocess the returned tdEls array with a for loop to extract from each tbEls[i] element its own innerText. It works but... My question is: In pure JS (no external libraries or

Why does JS code “var a = document.querySelector('a[data-a=1]');” cause error?

家住魔仙堡 提交于 2019-12-03 04:02:28
问题 I've an element in the DOM: <a href="#" data-a="1">Link</a> I want to get this element via its HTML5 custom data attribute data-a . So I write JS codes: var a = document.querySelector('a[data-a=1]'); But this code doesn't work and I get an error in browser's console. (I tested Chrome and Firefox.) JS code var a = document.querySelector('a[data-a=a]'); doesn't cause error. So I think the problem is that HTML5's JS API document.querySelector doesn't support to look for the number value in HTML5

document.querySelector with multiple values

会有一股神秘感。 提交于 2019-12-02 12:59:09
I have following codes in php which activates Optom button when select "p" from drop down but I would like to add more value so activate Optom when .value == "p" or .value == "u", I tried to add (document.querySelector(".motion").value == "p" || document.querySelector(".motion").value == "u") but it doesn't work: if (document.querySelector(".motion").value == "p"){ document.querySelector(".contantable").innerHTML = "<select class='sell_type' name='sell_type'><option value='1' " + sell_first + ">Optom</option></select><br><br>"; if (document.querySelector(".sell_type").value == "1"){ document