小编y2o*_*2ok的帖子

为什么jQuery每次输出相同的rel?

所以基本上这是我的脚本:

http://jsfiddle.net/JJFap/42/

代码 -

jQuery(document).ready(function() {
    var rel = new Array();
    var count = 0;
    jQuery(".setting").each(function() {
        rel[count] = [];
        if(jQuery("span").attr("rel")) {
            rel[count].push(jQuery("span").attr("rel"));
        }  
        console.log(count);
        count++;
    });               
    jQuery("body").text(rel);
    console.log(rel);
});?
Run Code Online (Sandbox Code Playgroud)

<div class="setting">
    <span rel="Variable">Variable</span>
    <span rel="Item">Item</span>
    <span rel="Something">Something</span>
</div>
<div>
    <span rel="Smth">Smth</span>
    <span>Sec</span>
</div>
<div class="setting">
    <span>Second</span>
    <span rel="first">First</span>
    <span rel="Third">Third</span>
</div>
Run Code Online (Sandbox Code Playgroud)

我的问题是,为什么它显示变量,变量?

我希望它显示变量,首先,但我无法做到.

基本上我想要实现的是创建新数组,其中插入每个div.setting span元素和rel属性数组.

所以基本上在这个例子中它应该输出 -

Array (

   Array[0] => "Variable","Item","Something";

   Array[1] => "first","Third";

)
Run Code Online (Sandbox Code Playgroud)

希望你明白我的意思:)

编辑:

在我的另一个例子中,我试图添加jQuery("span").每个(function()...在每个函数的第一个内部,但它输出两个完整的所有span元素的数组与rel.我不能有不同的类/ ids对于每个div元素,因为所有div元素都具有相同的类.

html javascript jquery

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

为什么!x将1和0更改为true/false

所以这是我的示例代码 - http://jsfiddle.net/JRqq3/.

它输出真/假而不是0/1为什么呢?

代码 -

x = 1;
for(i = 0; i < 20; i++) {
    x = !x;    
    $("body").append(x+"<br />");
}?
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

这个框架是什么?

所以基本上,只是偶然发现了PHP的框架或其他功能,我还没有看到.所有函数都是用PHP编写的 - oop类型,但是html文件真的很深(在文件夹中),这里是一个html文件的示例 -

http://jsfiddle.net/x2tgt/

代码 -

<h1>{$category[0].name}</h1>
<table cellpadding="0" cellspacing="0" width="100%">
    {section name=id loop=$products}
    <tr>
        {section name=id2 loop=$products[id]}
        {if $products[id][id2].id}
        <td width="100%" valign="top" width="130">
            <table cellpadding="1" cellspacing="0" width="100%">
                <tr>
                    <td valign="top" align="left" width="195">
                        <a href="{$smarty.const._URL_ROOT}/{$page.lang}/product/{$products[id][id2].id}/{if $page.eshop eq 1}1/{/if}"><img src="{$smarty.const._URL_PREFIX}/data/img/{$products[id][id2].filename}_list.jpg" alt="" /></a>
                    </td>
                    <td width="15"></td>
                    <td valign="top" align="left">
                        <a href="{$smarty.const._URL_ROOT}/{$page.lang}/product/{$products[id][id2].id}/{if $page.eshop eq 1}1/{/if}"><h1>{$products[id][id2].name}</h1></a>
                        {if $page.eshop eq 1}
                        <table cellpadding="0" cellspacing="0" class="prodListPrice">
                            <tr>
                                <td colspan="3" class="top">&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="middle">
                                    ##PROD_PRICE_1##<br/>
                                    <span>{$products[id][id2].price_1} {$products[id][id2].price_from|stripslashes}</span>
                                </td>
                                <td class="middle">
                                    ##PROD_PRICE_2##<br/>
                                    <span>{$products[id][id2].price_2} {$products[id][id2].price_from|stripslashes}</span>
                                </td>
                            </tr> …
Run Code Online (Sandbox Code Playgroud)

php frameworks

1
推荐指数
1
解决办法
102
查看次数

jQuery父母("tr")淡出不起作用

所以我试图用类"删除"父tr元素创建一个fadeOut效果.

这是我的jsfiddle,你可以在那里查看它 - http://jsfiddle.net/syTXZ/

和代码在这里 -

HTML -

<table border="1px solid black">
    <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Parent</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
    </thead>
    <tbody>
            <tr>
                <td>2</td>
                <td>test222</td>
                <td>test2</td>
                <td><a href="#" categoryID="1" class="edit">Edit Category</a></td>
                <td><a href="#" categoryID="1" class="delete">Delete Category</a></td>
            </tr>                                                    
            <tr>
                <td>1</td>
                <td>te1t22</td>
                <td>tes1t</td>
                <td><a href="#" categoryID="1" class="edit">Edit Category</a></td>
                <td><a href="#" categoryID="1" class="delete">Delete Category</a></td>
            </tr>  
            <tr>
                <td>3</td>
                <td>test2</td>
                <td>test</td>
                <td><a href="#" categoryID="1" class="edit">Edit Category</a></td>
                <td><a href="#" categoryID="1" class="delete">Delete Category</a></td>
            </tr>          
    </tbody>
</table>?
Run Code Online (Sandbox Code Playgroud)

和js -

$("a.delete").click(function() {
    $(this).parents("tr").fadeOut(300);
}?
Run Code Online (Sandbox Code Playgroud)

但它不起作用,任何线索?我也试过parent()而不是parent(),但它也没有用.

javascript jquery

1
推荐指数
1
解决办法
1510
查看次数

标签 统计

javascript ×3

jquery ×3

frameworks ×1

html ×1

php ×1