Is there a way to add a second class to an HTML tag using javascript? For example, say you had the element &lt;p class="a"&gt; and you wanted to add class="b". If you used document.getElementByClassName("a").class = "b" that would remove class "a". Is there a way to have both in the same element?
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?
97201
I have something like this:  &lt;div class="content"&gt;     &lt;a href="#"&gt;A&lt;/a&gt; &lt;/div&gt; &lt;div class="content"&gt;     &lt;a href="#"&gt;B&lt;/a&gt; &lt;/div&gt; &lt;div class="content"&gt;     &lt;a href="#"&gt;C&lt;/a&gt; &lt;/div&gt;   When one of these links is clicked, I want to perform the .hide() function on the links that are not clicked. I understand jQuery has the :not selector, but I can't figure out how to use it in this case because it is necessary that I select the links using $(".content a")  I want to do something like  $(".content a").click(function() {     $(".content a:not(this)").hide("slow"); });   but I can't figure out how to use the :not selector properly in this case.
20516
I've actually reached the bottom of Google trying to figure out how to add a css class to each row of a view.  The trick is that I need the class for each row to be dynamically determined based on some of the data from the node that the view pulls from.  The function that pulls this off neatly for the node is -   function pgc_preprocess(&amp;$variables) {   $node = $variables['node'];   if ($node-&gt;type == "event") {     $variables['event_class'] = '';     $num_trainers = $node-&gt;field_number_of_trainers[0]['value'];     $count = count($node-&gt;field_trainer);     if($count &lt; $num_trainers) {         $variables['event_class'] = 'red';     } else {         $variables['event_class'] = 'green';     }     return $variables;   } }   The point of this is to color code an event that hasn't had enough folks sign up.  There will be a list of events on the front page, and I need  them to be color coded also.  I really hope there some simple solution along the lines of -  function pgc_preprocess_views_view_unformatted(&amp;$variables) {   // Magic here, preferably having something to    // do with the function I already wrote. }   Just dropping &lt;?php print $event_class ?&gt; in the view .tpl doesn't do it.
50386
I have a code, that outputs a standard pager:  print theme('pager');   it outputs this:  &lt;h2 class="element-invisible"&gt;Pages&lt;/h2&gt; &lt;div class="item-list"&gt; &lt;ul class="pager"&gt;&lt;li class="pager-current first"&gt;1&lt;/li&gt; &lt;li class="pager-item"&gt;&lt;a title="Go to page 2" href="/drupal/node?page=1"&gt;2&lt;/a&gt;&lt;/li&gt; &lt;li class="pager-item"&gt;&lt;a title="Go to page 3" href="/drupal/node?page=2"&gt;3&lt;/a&gt;&lt;/li&gt; &lt;li class="pager-next"&gt;&lt;a title="Go to next page" href="/drupal/node?page=1"&gt;next ›&lt;/a&gt;&lt;/li&gt; &lt;li class="pager-last last"&gt;&lt;a title="Go to last page" href="/drupal/node?page=5"&gt;last »&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;   How can I change the HTML to something like this:  &lt;ul class="pagination"&gt;     &lt;li&gt;&lt;a href="#"&gt;&amp;lt;&lt;/a&gt;&lt;/li&gt;     &lt;li&gt;&lt;a href="#"&gt;1&lt;/a&gt;&lt;/li&gt;     &lt;li&gt;&lt;a href="#" class="active"&gt;2&lt;/a&gt;&lt;/li&gt;     &lt;li&gt;&lt;a href="#"&gt;3&lt;/a&gt;&lt;/li&gt;     &lt;li&gt;&lt;a href="#"&gt;&amp;gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;   I looked into this thread: , created a function bartik_preprocess_custom_pager and a file custom-pager.tpl.php inside my Bartic theme templates, but I can't make it work.  print theme('custom_pager');   outputs nothing. Does anybody know, how can I customize the HTML output for a pager, creating one just for 1 page?
76248
How can I use the &lt;label&gt; tag within an ASP.NET application? I want it to be valid, accessible, and usable.  I understand the optimal HTML way is this:  &lt;label for="Username"&gt;Username:&lt;/label&gt; &lt;input type="text" id="Username" runat="server" /&gt;   But if the above code is in an ASP.NET user control, the input ID will change, meaning the label's "for" attribute is useless. I could make the label tag a server control and set its "for" attribute in the code (Username.ClientID), but it seems like a lot of work for such a simple thing.  I've also seen this HTML used in the past:  &lt;label&gt;     &lt;span&gt;Username&lt;/span&gt;     &lt;input type="text" id="Username" runat="server" /&gt; &lt;/label&gt;   What is the proper approach?
111353
HTML (or maybe just XHTML?) is relatively strict when it comes to non-standard attributes on tags. If they aren't part of the spec, then your code is considered non-compliant.  Non-standard attributes can be fairly useful for passing along meta-data to Javascript however. For instance, if a link is suppose to show a popup, you can set the name of the popup in an attribute:  &lt;a href="#null" class="popup" title="See the Popup!"     popup_title="Title for My Popup"&gt;click me&lt;/a&gt;   Alternatively, you can store the title for the popup in a hidden element, like a span:  &lt;style&gt;     .popup .title { display: none; } &lt;/style&gt; &lt;a href="#null" title="See the Popup!" class="popup"&gt;     click me     &lt;span class="title"&gt;Title for My Popup&lt;/span&gt; &lt;/a&gt;   I am torn however as to which should be a preferred method. The first method is more concise and, I'm guessing, doesn't screw with search engines and screen readers as much. Conversely, the second option makes storing large amounts of data easier and is thus, more versatile. It is also standards compliant.  I am curious what this communities thoughts are. How do you handle a situation like this? Does the simplicity of the first method outweigh the potential downsides (if there are any)?
65851
Is there a well-supported, common behavior that I can expect if I do something like this in HTML:  &lt;form method="get" action="/somePage.html?param1=foo&amp;param2=foo"&gt;   &lt;input name="param2"&gt;&lt;/input&gt;   &lt;input name="param3"&gt;&lt;/input&gt; &lt;/form&gt;   Seems like this sort of thing is inherently ridiculous, but I've seen it used here and there and I was wondering what on Earth the expected behavior should be.  Are browsers smart enough to tack on "&amp;param2=whatever&amp;param3=whatever" to the action, or do they just throw in a second question mark?  Or what?  Are there cases where this is actually the right way to do things?
30966
I understand that an id must be unique within an HTML/XHTML page.  My question is, for a given element, can I assign multiple ids to it?  &lt;div id="nested_element_123 task_123"&gt;&lt;/div&gt;   I realize I have an easy solution with simply using a class. I'm just curious about using ids in this manner.
44392
Is it possible to use Javascript inside CSS?  If it is, can you give a simple example?
58948
I want my page to look something like this (using \documentclass{article}):     text       title       text   but I can't get it right, it puts my title on the next page leaving my first text paragraph on separate page. What should I do?
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?
63162
Let's say:  &lt;div&gt;   pre text   &lt;div class="remove-just-this"&gt;     &lt;p&gt;child foo&lt;/p&gt;     &lt;p&gt;child bar&lt;/p&gt;     nested text   &lt;/div&gt;   post text &lt;/div&gt;   to this:  &lt;div&gt;   pre text   &lt;p&gt;child foo&lt;/p&gt;   &lt;p&gt;child bar&lt;/p&gt;   nested text   post text &lt;/div&gt;   I've been figuring out using Mootools, jQuery and even (raw) JavaScript, but couldn't get the idea how to do this.
82642
I can understand that Favorite tags option helps us to highlight the questions on the list with selected tags. I'd like to know if we can add multiple tags to that. For eg., adding java+multithreading should highlight only those question which is both tagged as java and multithreading.
68766
I know it is possible to add new CSS classes definitions at runtime through JavaScript. But... How to change/remove CSS classes definitions at runtime? For instance, supose a I have the class below: &lt;style&gt; .menu { font-size: 12px; } &lt;/style&gt;  What I want is, at runtime, change the font-size rule of the .menu class, so that every element in the page who uses this class will be affected. And, I also want to know how to remove the .menu class definition.
27745
Is there a way to programmatically determine which document class is in effect?  I'd like to be able to write conditional macros that behave differently depending on which document class is currently being used.
11221
When embedding JavaScript in an HTML document, where is the proper place to put the &lt;script&gt; tags and included JavaScript? I seem to recall that you are not supposed to place these in the &lt;head&gt; section, but placing at the beginning of the &lt;body&gt; section is bad, too, since the JavaScript will have to be parsed before the page is rendered completely (or something like that). This seems to leave the end of the &lt;body&gt; section as a logical place for &lt;script&gt; tags.  So, where is the right place to put the &lt;script&gt; tags?  (This question references , in which it was suggested that JavaScript function calls should be moved from &lt;a&gt; tags to &lt;script&gt; tags. I'm specifically using jQuery, but more general answers are also appropriate.)
64820
If you know the Index, Value or Text. also if you don't have an ID for a direct reference.  ,  and  are all helpful answers.  Example markup  &lt;div class="selDiv"&gt;   &lt;select class="opts"&gt;     &lt;option selected value="DEFAULT"&gt;Default&lt;/option&gt;     &lt;option value="SEL1"&gt;Selection 1&lt;/option&gt;     &lt;option value="SEL2"&gt;Selection 2&lt;/option&gt;   &lt;/select&gt; &lt;/div&gt;