jquery-selectors

Get value of multiselect box using jQuery or pure JS

主宰稳场 提交于 2020-01-09 06:50:29
问题 In the code shown below, how to get the values of multiselect box in function val() using jQuery or pure JavaScript? <script> function val() { //Get values of mutliselect drop down box } $(document).ready(function () { var flag = 0; $('#emp').change(function () { var sub = $("OPTION:selected", this).val() if (flag == 1) $('#new_row').remove(); $('#topics').val(''); var html = '<tr id="new_row" class="new_row"><td>Topics:</td><td> <select id="topic_l" name="topic_l" class="topic_l" multiple=

addID in jQuery?

给你一囗甜甜゛ 提交于 2020-01-09 04:17:07
问题 Is there any method available to add IDs like there is for adding a class - addClass()? 回答1: ID is an attribute, you can set it with the attr function: $(element).attr('id', 'newID'); I'm not sure what you mean about adding IDs since an element can only have one identifier and this identifier must be unique. 回答2: do you mean a method? $('div.foo').attr('id', 'foo123'); Just be careful that you don't set multiple elements to the same ID. 回答3: Like this : var id = $('div.foo').attr('id'); $(

match elements with inline-style font-size for every absolute lengths units

爷,独闯天下 提交于 2020-01-07 05:45:09
问题 I need help for a jQuery fonction. Per say, i want to change the font-size of the whole document, first task is to increment the font size of the <body> tag in order to make all relative units, like em or rem, modified. But what about inlined font-size and old-timer <font size="x"> ? Also, i want to apply the modification to line-height so everything re-format nicely. Can someone help finish this code with a filter that will match : <font size="2"> <div style"font-size:14px;line-height:17px">

Remove li tags using javascript array

混江龙づ霸主 提交于 2020-01-07 05:36:08
问题 I'm searching a solution to remove <li> tags filtered using javascript array. Array: var mygroups=["1","8","3","4","5"] Example (input): <li><div>1 element.</div></li> <li><div>2 element. This is my <span>post</span> into new group</div></li> <li><div>3 element. Another one</li> <li><div> <a href="javascript:void(0);">Actor</a> <a href="/groups/viewgroup/1-first-group">First group</a> </div> </li> <li><div><a href="javascript:void(0);">Actor</a> <a href="/groups/viewgroup/10-ten-group">Ten

Focus selector not work

北城以北 提交于 2020-01-06 18:08:31
问题 Go into textfield and input a character. The debugger show you: $( document.activeElement ) => work, node found + attribute you can read $(":focus").css("background-color","red") => work $( ':focus' ) => not work, no node found Why? Any solutions? In API doc it's say $( document.activeElement ) is the $( ':focus' ). Only a performance difference. see: http://api.jquery.com/focus-selector/ Thanks! <html> <head> <title>focus</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1

JQuery checkbox manipulation within a foreach loop

寵の児 提交于 2020-01-06 14:00:56
问题 I have made a table as below. <div class="grid_top_button"> <div class="left_top_curve">  </div> <div class="right_top_curve">  </div> <input name="input" type="button" id="addSelected" name="addSelected" class="section_btn" value="Link" /> </div> <table id="LstDocTemp" border="0" cellpadding="0" cellspacing="0" class="instruction_grid"> <tr> <th align="left" class="ins_sl_no"> Sl No. </th> <th align="left" class="selct_column"> <input type="checkbox" id="chkSelectAll" name="chkSelectAll" />

jQuery selector on dynamic input value

喜欢而已 提交于 2020-01-06 03:45:10
问题 How can you use the :contain() on an input field, e.g. #inputfield contains a dynamic value of 5.938 and I want to use $("#inputfield:contains('5.938')") . But that won't work, I've provided a demo at jsFiddle. I don't want to use if(element.val() == '5.938') because I need a provisional selector instead doing an if/else statement. I also don't mean by using [value=5.938] because the value will change. 回答1: Due to @Neal's answer, you need to use some sort of conditional. A simple selector won

jQuery selector with nth-of-type()

假装没事ソ 提交于 2020-01-05 14:03:29
问题 Using Chrome Development Tools jQuery('.proejct-text-field') gives me four instances of HTML Elements: <div class=".proejct-text-field ...">...<> <div class=".proejct-text-field ...">...<> <div class=".proejct-text-field ...">...<> <div class=".proejct-text-field ...">...<> Trying the following doesn't return any Elements. jQuery('.proejct-text-field:nth-of-type(1)') As for my understanding the first Element should be returned. I just use jQuery in order to find the right selector for my

Jquery get nth-child having a particular class

此生再无相见时 提交于 2020-01-05 14:03:12
问题 I have a html table as follows <table id = "table1"> <tr> <td class="take">1</td> <td>2</td> <td>3</td> <td class="take">4</td> <td>5</td> <td class="take">6</td> </tr> <tr> <td class="take">11</td> <td>12</td> <td>13</td> <td class="take">14</td> <td>15</td> <td class="take">16</td> </tr> </table> I would like to get a jquery selector which gets me the second td having class of take in the first tr of table. :) funny huh? But it pains. I tried below. $("#table1").find('tr:first-child td.take

How to disable select based on other selected option?

烈酒焚心 提交于 2020-01-05 08:59:18
问题 I have a problem with jQuery function. I want based on one selected option to disable other select. In my case, I want to disable select2 if option 1 from select 1 is chosen. So i use this jQuery function: $(document).ready(function(e) { $('.select1').change(function(e) { if ($('.select1').val()==1){ $('.select2').attr('disabled','disabled'); } else{ $('.select2').removeAttr('disabled'); } }) }); But this works only if I first select option 2(or any other option form this select) and then