---
title: "给默认HTML增加自定义属性"
author: "john201314"
date: "2015-05-23T21:15:51Z"
tags: []
categories: ["Web前端"]
slug: "html"
draft: false
lastmod: "2015-05-23T21:15:51Z"
id: 2213760
url: "https://john201314.iteye.com/blog/2213760"
---

//获取值 btn.attributes\["strIp"].nodeValue //用js添加自定义值 var btn = document.getElementById("btnSubmit"); btn.setAttribute("strIp","222"); jQuery操作 $("#btnSubmit").attr("strIp","test"); alert($("#btnSubmit").attr("strIp"));