通过单击将span标记替换为多个链接

时间:2012-10-24 04:30:40

标签: jquery html css jquery-ui css3

当我点击此标签时,弹出窗口会打开

<span class="en_US tk-museo-sans locale-select-lable">United States</span>

当我点击弹出窗口内的链接时弹出窗口关闭

<span class="selectorCountries locale-link">united states</span>
<span class="selectorCountries marginSecondCountry locale-link">canada</span>
<span class="selectorCountries marginCanadaFrench locale-link">canada(french)</span>

问题是当我点击弹出此标签内的链接

<span class="en_US tk-museo-sans locale-select-lable">United States</span> 

应替换为国家/地区名称...

问题在于jquery代码......

http://jsfiddle.net/6QXGG/145/

你可以告诉我如何解决它......

我正在提供我最新的js代码

    // locale selector actions
    $('#region-picker').click(function(){
            if ($("#locale-select").is(":visible")) return closeSelector('slide');


        var foot_height = $('#footer').innerHeight();
        var foot_height_css = foot_height-1;
        var select_position = '-=' + (Number(700)+18);
        console.log("hallo"+select_position);
        var $selector = $('#locale-select');
        $('#locale_pop').fadeOut();
        $selector.css({top:foot_height_css});
        $selector.fadeIn(function(){
            $(this).addClass('open');
            $(this).animate({top:select_position}, 1000);
            });
    });
    $('#select-tab').click(function(e){
        e.stopPropagation()
        closeSelector('slide');
        });
    // don't hide when clicked within the box
    $('#locale-select').click(function(e){
        e.stopPropagation();
    });
    $(document).click(function(){ 
        if ($('#locale-select').hasClass('open')) {
            closeSelector('disappear');
        }
    });

    $('.locale-link').click(function(){
        if ($("#locale-select").is(":visible")) return closeSelector('slide');
       /*         
       // var desired_locale = $(this).attr('rel');
       // createCookie('desired-locale',desired_locale,360);
       // createCookie('buy_flow_locale',desired_locale,360);
        //closeSelector('disappear');
        */
    })

    $('#locale_pop a.close').click(function(){
        var show_blip_count = readCookie('show_blip_count');
        if (!show_blip_count) {
            createCookie('show_blip_count',3,360);
        }
        else if (show_blip_count < 3 ) {
            eraseCookie('show_blip_count');
            createCookie('show_blip_count',3,360);
        }
        $('#locale_pop').slideUp();
        return false;
    });

function closeSelector(hide_type){
var foot_height = $('#footer').innerHeight();
var select_position = '+=' + (Number(400)+20);
if (hide_type == 'slide') {
$('#locale-select').animate({top:select_position}, 1000, function(){
$(this).removeClass('open');
$(this).fadeOut()
});
}
else if (hide_type == 'disappear'){
$('#locale-select').fadeOut('fast');
$('#locale-select').removeClass('open');
}
}

1 个答案:

答案 0 :(得分:0)

这个怎么样?

 $('.locale-link').click(function(){
        $("#region-picker:first-child").text(this.text());
        if ($("#locale-select").is(":visible")) return closeSelector('slide');
   })