标签: jquery-selectors

jQuery 在其中选择 p

我在选择单击的 ID 内的 ap 标签时遇到一些问题,代码如下;

<tbody>
    <tr id="test1">
    <p>
        Some random text that should show up in the dialog.
    </p>
        <td>test</td>
        <td>test</td>
    </tr>
    ... the rest of the tr's are identical, nothing else to see here.
 </tbody>


$('#test1, #test2, #test3, #test4').click(function(){
    $(this 'p').dialog();
});
Run Code Online (Sandbox Code Playgroud)

现场测试;http://team-blandsaft.no-ip.org/

最好习惯在 stackoverflow 编辑器中编写一些代码。

html jquery jquery-ui jquery-selectors

-2
推荐指数
1
解决办法
1万
查看次数

元素ID未被识别且未触发功能

我正在尝试在选择特定字体样式时为用户创建简单的选择选项.如果他们点击字体div,其背景div应该改变颜色.

我遇到的问题是第一种字体div在改变颜色时效果很好 - 但是其他字体div并不适用.

的jsfiddle

HTML

<div class="fonts">
  <div id="font" class="minecraft-evenings">
      Hello
      <p>Minecraft Evenings</p>
  </div>
  <div id="font" class="minecrafter">
      Hello
      <p>Minecrafter 3</p>
  </div>
  <div id="font" class="volter">
      Hello
      <p>Volter</p>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

的JavaScript/JQuery的

$(document).ready(function() {
    $('#font').click(function() {
        $(this).css("background-color", "#000");
        $('#font').not(this).css("background-color", "#f1f1f1");
    });
});
Run Code Online (Sandbox Code Playgroud)

html javascript jquery dom jquery-selectors

-2
推荐指数
1
解决办法
119
查看次数

如何在div中选择img src属性?

我需要使用什么选择器来获取此图片的src值?

<div class="rg-image">
    <img src="/zenphoto/cache/test2/6244146_460s_595_watermark.jpg">
</div>
Run Code Online (Sandbox Code Playgroud)

jquery jquery-selectors

-2
推荐指数
2
解决办法
5399
查看次数

在 querySelector 中使用变量和 id

我想使用 querySelector 从输入列中获取值。我需要使用两个 id 来获取正确的列。第二个 id 存储在变量中,它是一个整数值。我尝试过不同的事情,但我没有得到任何东西。目前它给我空。

 checkDescriptionField = document.querySelector('#methodProperties input#'+'descriptionFieldId'); 
 if(typeof checkDescriptionField !== 'undefined' && checkDescriptionField !== null)
        {
            descriptionFieldValue = document.querySelector('#methodProperties input#'+'descriptionFieldId').textContent; 
        }
Run Code Online (Sandbox Code Playgroud)

外部 id 是 methodProperties ,内部是 input id="0eca409e-e2f7-467d-bd5e-dff9b63e3715" ,我想获取其值 ="Customers"

<div id="methodProperties">
<td role="gridcell">
<input id="0eca409e-e2f7-467d-bd5e-dff9b63e3715" class="k-textbox gridTable propertiesField" value="Customers" readonly="" data-role="droptarget"   type="text">
<span class="errorTooltip" style="display: none;">
<span class="deleteTooltip" style="padding: 5px; display: inline;" title="Delete Value" data-role="tooltip">
</td>
Run Code Online (Sandbox Code Playgroud)

我尝试了这个,但收到无效错误

checkDescriptionField = document.querySelector('#methodProperties input#'+descriptionFieldId); 
if(typeof checkDescriptionField !== 'undefined' && checkDescriptionField !== null)
        {
            descriptionFieldValue = document.querySelector('#methodProperties input#'+descriptionFieldId).textContent; 
        }
Run Code Online (Sandbox Code Playgroud)

javascript jquery-selectors

-2
推荐指数
1
解决办法
7345
查看次数

为什么 jQuery 选择器在这里不起作用?

我想知道为什么当我在创建英雄后尝试更新表格单元格时,id 的 jQuery 选择器在这里不起作用。我使用的是基本的 jQuery 选择器,但即使使用 innerHTML 它也不会执行任何操作。jQuery 选择器正在处理输入获取值函数,但之后就没有了,这对我来说毫无意义,控制台绝对没有给我任何错误。

HTML

<div class="col-4 hero">
    <h2>Votre personnage</h2>
    <div>
        <h3>Créer un nouveau personnage</h3>
        <p class="alert alert-danger" role="alert">Attention ! créer un nouveau personnage supprimera tout de l'ancien.</p>
        <label>Nom</label>
        <input type="text" id="hero_name_input" name="hero_name_input">
        <button>Créer personnage</button>
    </div>
    <div>
        <h3>Les statistiques de votre personnage</h3>
        <table>
            <tr>
                <th>Nom</th>
                <td id="Hname"></td>
            </tr>
            <tr>
                <th>Habilité</th>
                <td id="Hskill"></td>
            </tr>
            <tr>
                <th>Endurance</th>
                <td id="Hstamina"></td>
            </tr>
            <tr>
                <th>Chance</th>
                <td id="Hluck"></td>
            </tr>
        </table>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

JS

$(document).ready(function() {

    $('.hero button').click( function create_hero() {
        let …
Run Code Online (Sandbox Code Playgroud)

javascript jquery dom onclick jquery-selectors

-2
推荐指数
1
解决办法
73
查看次数

div中的jQuery Selector

嗨,我是jQuery的新手.

我有以下HTML块:

<html>
<body>
    <p>Paragraph1</p>
    <p>Paragraph2</p>
    <div id = "mydiv">
        <p>Paragraph3</p>
        <p>Paragraph4</p>
    </div>
 </body>
</html>
Run Code Online (Sandbox Code Playgroud)

如果我做$("p"),那么这将选择每个段落.但是我如何选择"mydiv"中的所有段落

谢谢!

jquery jquery-selectors

-3
推荐指数
2
解决办法
200
查看次数

我如何编写一个jQuery选择器来获取$(this)的子<input>?

我试过了:

$(this).nextAll("input").get(0)
Run Code Online (Sandbox Code Playgroud)

它不仅不起作用,看起来如果它确实会有点过分.

jquery jquery-selectors

-3
推荐指数
1
解决办法
52
查看次数

在jquery中设置HTML的文本框?

下面我使用这个脚本来设置文本框值..

    $('#sub').click(function(){

     var num1 = $('#text1').val(); 
     var num2 = $('#text2').val();

     var newVal = (num1+2)*(num2/4);
     var nextVal =(num1+4)*(num2/2);
     $(#text1).val(newVal); //setting the textbox value here    
Run Code Online (Sandbox Code Playgroud)

jquery jquery-selectors

-4
推荐指数
1
解决办法
69
查看次数

不同范围内的多个Id选择器?

Id元素在整个文档中是唯一的,没关系.这个怎么样

$("#Genders", $("#tableFor_SEARCH")).buttonset();
Run Code Online (Sandbox Code Playgroud)

$("#Genders", $("#tableFor_CREATE")).buttonset();
Run Code Online (Sandbox Code Playgroud)

firefox看起来还不错,这个用法可以接受所有浏览器和任何缺点吗?

注意:我尝试这种用法,因为jquery使用id选择器和radio&checkbox助手(特别是标签标签)

html jquery jquery-selectors

-10
推荐指数
3
解决办法
1919
查看次数

标签 统计

jquery-selectors ×9

jquery ×8

html ×3

javascript ×3

dom ×2

jquery-ui ×1

onclick ×1