javascript - 使用 Javascript .click 插入 Css(为时已晚)

标签 javascript css

我正在处理我的代码,它的工作是,但 Action (插入 css)是 Action 的后期。

jQuery(document).ready(function() {

     jQuery("#cal2tozindex").click(function() {
      jQuery("#cal2tozindex").css('z-index','1000');
      jQuery("#cal3tozindex").css('z-index','1');
     });

     jQuery("#cal3tozindex").click(function() {
      jQuery("#cal3tozindex").css('z-index','1000');
      jQuery("#cal2tozindex").css('z-index','1');
     });

});

有 url,您可以在该部分的右侧,然后单击上面有一个名为“vols”的平面的 bleu 按钮。 http://www.voyagesendirect.me/multisites/esther/

我想要什么:

When you click on the first field : 'date de départ' (cal2tozindex) he should became with a z-index:1000; and the other field : 'date de retour' (cal3tozindex) should be with z-index:1;

Same patern with you click on the second field.

我的实际问题:

css 的插入太晚了,javascript 在您单击日期之后放置了 css,而不是在您首先单击该字段时放置了 css。我真的需要代码在第一次点击时(在现场)而不是在第二次点击时(在某个日期)起作用。

感谢大家帮我解决这个问题!

最佳答案

jQuery(document).ready(function() {        
    jQuery("#date_dep_calFLT").focus(function() {
    jQuery("#cal2tozindex").css('z-index','1000');
    jQuery("#cal3tozindex").css('z-index','1');
});
jQuery("#bt-cal_FLT").click(function() {
    jQuery("#cal2tozindex").css('z-index','1000');
    jQuery("#cal3tozindex").css('z-index','1');
});

jQuery("#date_ret_calFLT").focus(function() {
    jQuery("#cal3tozindex").css('z-index','1000');
    jQuery("#cal2tozindex").css('z-index','1');
});

jQuery("#bt-cal_FLT_ret").click(function() {
    jQuery("#cal3tozindex").css('z-index','1000');
    jQuery("#cal2tozindex").css('z-index','1');
});

});

关于javascript - 使用 Javascript .click 插入 Css(为时已晚),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11033325/

相关文章:

用于 twitter-bootstrap 的固定导航栏的 Javascript 在链接多个页面时不起作用?

php - 将 php 数组重新排列为 javascript 数组问题

javascript - "______ is not defined"异常,不知道为什么

internet-explorer-8 - CSS3 Pie 在 IE8 中不工作

javascript - 如何阻止切换更改侧导航栏的宽度?

HTML/CSS/Ruby on Rails header ,带有突出到页面内容中的 Logo

css - Sprite 出现在按钮上的问题

javascript - 如何在 Angular 工厂内定义ngModel?

javascript - Array.prototype.flat() 无法在使用 Node JS 的命令行中工作

javascript - 动态更改 Youtube Iframe playerVars