变量和jQuery:如何捕获值(第1部分) [英] variables and jquery: how capture value (part 1)

查看:79
本文介绍了变量和jQuery:如何捕获值(第1部分)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在<ul><li>列表中捕获一个值.

I must capture a value in a <ul><li> list.

我这样做:

function capture(){

    $('#country_list li a').mouseover(function(a){
    $(this).addClass('selected');
    var $regionMap = '#'+ $(this).attr('id');
    alert($regionMap); // control
    });

    $('#country_list li a').mouseout(function(){
    $(this).removeClass('selected');

    }); 
}

selected CSS类是

.selected 
    {
     background-color: #FFFFFF;
    }

该功能还可以,我可以通过以下方式在HTML中激活该功能:

The function is ok and I activate in HTML the function with:

<ul id="country_list" style="list-style-type:none" onmouseover="capture();">

我不确定这是正确的.你对我有帮助吗?

I'm not sure that this is correct. Do you have any help for me?

我已经发布了第二个问题,更重要的是,与此相关的名称是:

I have posted a second question, more important, linked with this, and the name is:

变量和jquery:如何捕获和使用值(第2部分)

variables and jquery: how capture value and use them (part 2)

推荐答案

听起来不错,只是您可以用css之类的css代替css操作

Sounds perfectly ok, just you could replace the css manipulation with a css like

#country_list li a:hover {
   background-color: #FFFFFF;
}

这篇关于变量和jQuery:如何捕获值(第1部分)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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