logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ

by Admin _ May 06, 2022

With the help of JQuery, you can get HTML values easily. In this tutorial, I will let you know how you can get attribute values. JQuery is a very simple but powerful Javascript plugin and widely used in web development.

Bạn đang xem:

How lớn install JQuery into your Project?

It is very simple you just need to download JQuery plugin on its official site or you can địa chỉ cửa hàng JQuery CDN that directly loads JQuery into your project. In this tutorial, I will use Bootstrap 4 & JQuery as a CDN.

Below snippet is bootstrap 4 snippets.


We can get HTML attribute values with the help of JQuery attr() function. You can also mix an attribute with the same function. And there is an HTML5 data attribute getting function also in JQuery data() that retrieves all data element values.

With the help of data() function you only able khổng lồ get data to lớn attribute values. But the help of attr() function you can get any attribute value lượt thích name, id, text & any other self define attribute values. The below code shows how you can use both functions.

Xem thêm: array_fill() trong php


$(document).ready(function(e) $("#userForm").on("submit",function()var user=$("#user").attr("data-user");var userId=$("#user").attr("data-user-id");console.log(user+" "+userId);var user=$("#user").attr("data-user");console.log(user);var data=$("#email").data();console.log(data);););
darkedeneurope.com”, userId: 1}

You can also get select option attribute values with the help of JQuery for that use below code.


$(document).ready(function(e) $("#userForm").on("submit",function()var city=$("#city option:selected").data();console.log(city);var state=$("#state option:selected").attr("data-state");console.log(state);););

Output:

city: 32

You can also get all the values of any khung with the help of .serialize() the JQuery function.


$(document).ready(function(e) $("#userForm").on("submit",function()var fData = $(this).serialize(); console.log(fData);););
The above function will return all element values in the khung of string.

Output:

user=&email=&city=city3&state=state2

You can also set an attribute with the help of attr() function. attr(‘getAttribute’,’setAttribute’); the below example shows how you can phối attribute of an HTML element.


$(document).ready(function(e) $("#user").attr("userName","Test"); //Set attributevar user=$("#user").attr("userName"); //Get Attributeconsole.log(user););
Prev" class="btn btn-orange-dark btn-lg my-2" data-bs-toggle="tooltip" data-bs-placement="top" title="How lớn use Instascan an HTML5 QR scanner"> Prev " class="btn btn-orange-dark btn-lg my-2" data-bs-toggle="tooltip" data-bs-placement="top" title="Add or Remove array value with Javascript and JQuery">Next

*
Login with Facebook using PHP SDK
*
How lớn use Instascan an HTML5 QR scanner
*
địa chỉ More rows into the existing table with PHP & JQuery
*
Reorder Bootstrap 4 table rows with PHP, JQuery

Name

Email

*

AJAXAPIarrayBootstrapBootstrap 4CSSDatabasedo while loopDropzoneelseif/else ifFacebookfgetcsvFontsfopenForeach LoopFor LoopFront kết thúc developmentHTMLHTML5JavaScriptJQueryJQuery PluginLets EncryptLoginLoopMobileAppMySqlMySqliPDOPhoneGapPHPPhpSpreadsheetReact JSReorderSnippetSortingSQLSQL ConstraintsSSLswitchtypescriptVue Jsweb developmentWhile LoopWordPress
Share Tweet Linkedin Pinterest
Previous Post

Kiểm tra form hợp lệ với jquery

Next Post

Jquery unveil

CÙNG CHUYÊN MỤC

jquery file upload (hayageek plugin) error case with json from php

Jquery file upload (hayageek plugin) error case with json from php

28/04/2021
search/filter table rows based on input

Search/filter table rows based on input

28/04/2021
jquery form validation before ajax submit

Jquery form validation before ajax submit

18/03/2021
jquery multiple select dropdown

Jquery multiple select dropdown

28/04/2021
jquery form validation before ajax submit, easy form validation with jquery

Jquery form validation before ajax submit, easy form validation with jquery

25/05/2022
top 17 jquery foreach json array hay nhất 2022

Top 17 jquery foreach json array hay nhất 2022

24/05/2022
how to upload files asynchronously using jquery?

How to upload files asynchronously using jquery?

23/05/2022

22/05/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • Bí quyết giữ chàng trên giường

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.