Is it possible to read a CSS class attribute value before the class is added to an HTML element using javascript?   .myclass {     color: #00aa00;   }   For example, how can I read the "color" attribute value of "myclass" before the "myclass" added to an HTML element?
10666
I would like to return a string with all of the contents of a CSS rule, like the format you'd see in an inline style. I'd like to be able to do this without knowing what is contained in a particular rule, so I can't just pull them out by style name (like .style.width etc.)   The CSS:  .test {     width:80px;     height:50px;     background-color:#808080; }   The code so far:  function getStyle(className) {     var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules     for(var x=0;x&lt;classes.length;x++) {         if(classes[x].selectorText==className) {             //this is where I can collect the style information, but how?         }     } } getStyle('.test')
77342
Is it possible to to change a &lt;span&gt; tag (or &lt;div&gt;) to preformat its contents like a &lt;pre&gt; tag would using only CSS?
28047
Is there any syntactical way in jQuery to define multiple CSS attributes without stringing everything out to the right like this:  $("#message").css("width", "550px").css("height", "300px").css("font-size", "8pt");   If you have, say, 20 of these your code will become hard to read, any solutions?  From jQuery API, for example, jQuery understands and returns the correct value for both   .css({ "background-color": "#ffe", "border-left": "5px solid #ccc" })    and   .css({backgroundColor: "#ffe", borderLeft: "5px solid #ccc" }).   Notice that with the DOM notation, quotation marks around the property names are optional, but with CSS notation they're required due to the hyphen in the name.
67600
I am using style attribute to use media queries in lightning components something like this:  &lt;style&gt;   .legendBox {     background: none!important;     min-height: 50px;     padding: 5px 0px;     position: absolute;     width: 90%!important;     left:9%;     margin-top:-15.25%!important;     border:0px!important;   }    .bootstrap-sf1 .pre-scrollable {     max-height:none!important;                   overflow:none!important;   }  &lt;/style&gt;   My question is how to use these media queries in css section of lightning component. If possible please suggest the method as I am trying to submit the code for security review. Will it fail there?
58009
I wanted to set a CSS class in my master page, which depends on the current controller and action. I can get to the current controller via ViewContext.Controller.GetType().Name, but how do I get the current action (e.g. Index, Show etc.)?
67133
I have the following element element(by.css(&quot;span[aria-label='Picker ID, TESTUSER']&quot;)  I want to assure the text on this filed is TESTUSER, so I tried:  expect(element(by.css(&quot;span[aria-label='Picker ID, TESTUSER']&quot;)).getAttribute('value')).toEqual('TESTUSER');  then I got the error: Expected null to equal 'TESTUSER' So I tried: element(by.css(&quot;span[aria-label='Picker ID, TESTUSER']&quot;)).getText().then(function (value) {         console.log(value);       })  And I got this error: Expected '' to be 'TESTUSER'.  How to get the value of this field and expect it is TESTUSER?
38027
I need a way to determine the type of an HTML element in JavaScript. It has the ID, but the element itself could be a &lt;div&gt;, a &lt;form&gt; field, a &lt;fieldset&gt;, etc. How can I achieve this?
105678
My code looks like this:  &lt;ul id="ulList"&gt;   &lt;li class="listClass" id="id1"&gt;&lt;a href="http://link1"&gt;Link 1&lt;/a&gt;&lt;/li&gt;   &lt;li class="listClass" id="id2"&gt;&lt;a href="http://link2"&gt;Link 2&lt;/a&gt;&lt;/li&gt;   &lt;li class="listClass" id="id3"&gt;&lt;a href="http://link3"&gt;Link 3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;   Now I like to get the following:  All links as an array  All ids of li as an array  Can someone help me please?
69079
I need to edit (using javascript) an SVG document embedded in an html page.  When the SVG is loaded, I can access the dom of the SVG and its elements. But I am not able to know if the SVG dom is ready or not, so I cant' perform default actions on the SVG when the html page is loaded.  To access the SVG dom, I use this code:  var svg = document.getElementById("chart").getSVGDocument();   where "chart" is the id of the embed element.  If I try to access the SVG when the html document is ready, in this way:  jQuery(document).ready( function() { var svg = document.getElementById("chart").getSVGDocument(); ...   svg is always null. I just need to know when it is not null, so I can start manipulate it. Do you know if there is a way to do it?
31158
Let's say I have an html form.  Each input/select/textarea will have a corresponding &lt;label&gt; with the for attribute set to the id of it's companion. In this case, I know that each input will only have a single label.  Given an input element in javascript &mdash; via an onkeyup event, for example &mdash; what's the best way to find it's associated label?
62871
If my html looked like this:  &lt;td class="controlCell"&gt;     &lt;input class="inputText" id="SearchBag.CompanyName" name="SearchBag.CompanyName" type="text" value="" /&gt; &lt;/td&gt;   How could I select #SearchBag.CompanyName with JQuery? I can't get it to work and I fear it's the dot that's breaking it all. The annoying thing is that renaming all my id's would be a lot of work, not to mention the loss in readability.  Note: Please let's not start talking about how tables are not made for lay-outing. I'm very aware of the  and try hard to use it as much as possible.
20773
How do you use the CSS content property to add HTML entities?  Using something like this just prints &amp;nbsp; to the screen instead of the non-breaking space:  .breadcrumbs a:before {     content: '&amp;nbsp;'; }
17274
How do you get the rendered height of an element?  Let's say you have a &lt;div&gt; element with some content inside. This content inside is going to stretch the height of the &lt;div&gt;. How do you get the "rendered" height when you haven't explicitly set the height. Obviously, I tried:    var h = document.getElementById('someDiv').style.height;   Is there a trick for doing this? I am using jQuery if that helps.
4670
I have an element that already has a class: &lt;div class=&quot;someclass&quot;&gt;     &lt;img ... id=&quot;image1&quot; name=&quot;image1&quot; /&gt; &lt;/div&gt;  Now, I want to create a JavaScript function that will add a class to the div (not replace, but add). How can I do that?
52458
I am creating a jQuery plugin.  How do I get the real image width and height with Javascript in Safari?  The following works with Firefox 3, IE7 and Opera 9:  var pic = $("img")  // need to remove these in of case img-element has set width and height pic.removeAttr("width");  pic.removeAttr("height");  var pic_real_width = pic.width(); var pic_real_height = pic.height();   But in Webkit browsers like Safari and Google Chrome values are 0.
85136
All right, say I have this:  &lt;select id='list'&gt;     &lt;option value='1'&gt;Option A&lt;/option&gt;     &lt;option value='2'&gt;Option B&lt;/option&gt;     &lt;option value='3'&gt;Option C&lt;/option&gt; &lt;/select&gt;   What would the selector look like if I wanted to get "Option B" when I have the value '2'?  Please note that this is not asking how to get the selected text value, but just any one of them, whether selected or not, depending on the value attribute. I tried:  $("#list[value='2']").text();   But it is not working.
8401
I have a drop-down list with known values. What I'm trying to do is set the drop down list to a particular value that I know exists using jQuery.  Using regular JavaScript, I would do something like:  ddl = document.getElementById("ID of element goes here"); ddl.value = 2; // 2 being the value I want to set it too.   However, I need to do this with jQuery, because I'm using a CSS class for my selector (stupid  client ids...).  Here are a few things I've tried:  $("._statusDDL").val(2); // Doesn't find 2 as a value. $("._statusDDL").children("option").val(2) // Also failed.      How can I do it with jQuery?     Update  So as it turns out, I had it right the first time with:  $("._statusDDL").val(2);   When I put an alert just above it works fine, but when I remove the alert and let it run at full speed, I get the error     Could not set the selected property. Invalid Index   I'm not sure if it's a bug with jQuery or Internet Explorer 6 (I'm guessing Internet Explorer 6), but it's terribly annoying.