• 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

How to get Laravel's CSRF Token from Another Website?

WooCommerce: Add/display Product or Variation custom field everywhere

Shortcode or PHP inside a shortcode in Wordpress

Stop caching for PHP 5.5.3 in MAMP

Redis Command To Sort Keys

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Post Form Data To phpmyadmin Database

Ajax GET request fails in laravel 8

calling server using nusoap with complextype

Laravel Command Schedule Not Working Properly

Laravel Jetsream Profile page not loading on fresh install

Only on Firefox "Loading failed for the <script> with source"

Return new collection without modifying original collection

CodeIgniter 3 is generating a session file on each request, why?

protect images from being copied

About Contact Privacy policy Terms and conditions