ITPub博客

首页 > IT职业 > IT职场 > jquery基本操作增删改查有哪些?

jquery基本操作增删改查有哪些?

原创 IT职场 作者:专注的阿熊 时间:2020-01-08 16:18:38 0 删除 编辑

//添加类名active,遍历兄弟元素,删除兄弟元素中的active
$(this).addClass('active').siblings().removeClass('active');


//获取父元素类名为name的元素下的子元素类名为price
$(this).parents('.name').find('.price')

//父元素box后追加html代码
$(this).parents('.box').append(html)


//JQ获取自定义data属性
$(this).data('id')

//input获取焦点
$("input").focus();
$("input").focus(function() {});
$("input").blur();
$("input").blur(function() {})


//删除指定字符串
//replace('参数1需要删除的字符串','参数2为空,则只删除')
var money2 = $('#order_price').text().replace('元', '') //支付金额



//字符串转数字MT4问题汇总http://www.gendan5.com/operation.html



parseFloat(money1) //小数
parseInt(money1) //整数


//dom元素隐藏显示判断
if (document.getElementById("div").css("display") === 'none') {}
if (document.getElementById("div").css("display") === 'block') {}
setTimeout(function() {
    console.log(_this.parents('.name').find('.city-picker-dropdown').is(':visible'))
    if (_this.parents('.name').find('.city-picker-dropdown').is(':visible') == false) {
        console.log('隐藏')
    } else {
        console.log('显示')
    }
}, 100)


//键盘事件,按下的键值code
$("#inputval").bind('keydown', 'down',function (event){
    console.log(event.keyCode)
})



//浏览器左上角返回判断,刷新页面
if(window.performance.navigation.type == 2){
    console.log('返回')
    window.location.replace(window.location.href);
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69946337/viewspace-2672493/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-23

  • 博文量
    410
  • 访问量
    276819