• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

get data-value with variable value

javascriptphp


PHP Snippet 1:

<a id="element_with_k" class="dropdown-item" data-value="<?= $k ?>"></a>

PHP Snippet 2:

const elementWithK = document.getElementById('element_with_k');

elementWithK.dataset.value // "the content of $k"

Related Snippets

What is the function of the (new Date()).getTime() in PHP?

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

php mysql + create a friend request system

MySQL order by field in Eloquent

Creating command to backup MySql database in Laravel

Having trouble with PDO queries (Notice: Undefined index)

Laravel Nova, route not found

Yii2 select2 database exception number of bound variables does not match number of tokens

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Eloquent insert id with sequence next value

Twig - How to check if variable is a number / integer

Pages are working fine on localhost but not running on the hosting server

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

Explode not working properly with dash

Woocommerce Checkout - Add conditional field required if one field is filled

About Contact Privacy policy Terms and conditions