如何使用查询在图像中使用追加 [英] how to use append in image using query

查看:92
本文介绍了如何使用查询在图像中使用追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用查询在图像中使用追加



 <   div     id   =  container    class   =  hidden >  
< p > ; 有0个框< / p >

< a href = \ compare.html?a = 123& b = 124& c = 125 class = compare_link > 比较< / a >
< div id = close class = close >
x
< / div >


< / div > < / div >
< pre lang = xml > & lt; div class =& quot; add& quot;& gt;

< div class = 添加 >

< a href = class = more > +添加比较< / a >
< span class =code-keyword >< span class = ProdId > < img id = rvw_img class = rvw_img src = / images / compare.png / > < / span >
< / div >
< / div >
< script >
function getSelectedIds(){
return $ ('.box_compare .prod-id')。map(function(){return $(this).text(); })指定者();
}

函数updateLinkAndCounter(){
var ids = getSelectedIds()。map(function(x,i){return ['P',++ i,'= ',x] .join('');});
$('#container> a')。attr('href','Compare.html?'+ ids.join('&'));
$(p)。text(ids.length == 1?'有1个方框。':'有'+ ids.length +'方框。');
}

$(。more)。click(function(){
var id = $(this).next('。ProdId')。text() ;

var selected = getSelectedIds();
if(selected.length == 5)return; //已经添加4项
if(selected.indexOf(id)! = -1)return; //已添加项目

$('< div / > ', {'class':'box_compare'})
.append($('< span / > ',{class :'prod-id',text:id}))
.append($('< a / > ',{href:'#',text:'x'}))
.appendTo('#container');

updateLinkAndCounter();
$(#container)。removeClass(hidden);
});

$(。box_compare a)。live(click,function(){
$(this).parent()。remove();
updateLinkAndCounter( );
});
< / script >

解决方案

('。box_compare .prod-id')。map(function(){return


(this).text();})。toArray();
}

函数updateLinkAndCounter(){
var ids = getSelectedIds()。map(function(x,i){return ['P',++ i,'= ',x] .join('');});


('#container> a')。attr('href','Compare.html?'+ ids。加入( '&安培;'));

how to use append in image using query

<div id="container" class="hidden">
            <p>There are 0 boxes</p>

            <a href="\compare.html?a=123&b=124&c=125" class="compare_link">Compare</a>
            <div id="close" class="close">
                x
            </div>

        </div> </div>
<pre lang="xml">&lt;div class=&quot;add&quot;&gt;

                              <div class="add">
                             
                               <a href="#" class="more"> + Add to compare</a>
                               <span class="ProdId"> <img id="rvw_img" class="rvw_img" src="/images/compare.png"  /></span>
                       </div> 
                </div>
<script>
    function getSelectedIds() {
        return $('.box_compare .prod-id').map(function () { return $(this).text(); }).toArray();
    }

    function updateLinkAndCounter() {
        var ids = getSelectedIds().map(function (x, i) { return ['P', ++i, '=', x].join(''); });
        $('#container > a').attr('href', 'Compare.html?' + ids.join('&'));
        $("p").text(ids.length == 1 ? 'There is 1 box.' : 'There are ' + ids.length + ' boxes.');
    }

    $(".more").click(function () {
        var id = $(this).next('.ProdId').text();

        var selected = getSelectedIds();
        if (selected.length == 5) return; // already 4 items added
        if (selected.indexOf(id) != -1) return; // item already added

        $('<div />', { 'class': 'box_compare' })
           .append($('<span />', { class: 'prod-id', text: id }))
           .append($('<a />', { href: '#', text: 'x' }))
           .appendTo('#container');

        updateLinkAndCounter();
        $("#container").removeClass("hidden");
    });

    $(".box_compare a").live("click", function () {
        $(this).parent().remove();
        updateLinkAndCounter();
    });
</script>

解决方案

('.box_compare .prod-id').map(function () { return


(this).text(); }).toArray(); } function updateLinkAndCounter() { var ids = getSelectedIds().map(function (x, i) { return ['P', ++i, '=', x].join(''); });


('#container > a').attr('href', 'Compare.html?' + ids.join('&'));


这篇关于如何使用查询在图像中使用追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆