• 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 can I access an array/object?

How can I easily switch between PHP versions on Mac OSX?

How can I pass the list to the component variable in Laravel?

Adding hreflang tags automatically in WordPress subdirectory multisite

Sort multidimensional array by column value within a column

Remove country code from phone number?

Saving Data from form to database using AngularJS and php

How can I get user id from session in javascript?

I can't delete my image when it is liked because of the foreign key in mysql

How to set dynamic `home` and `siteurl` in WordPress?

Chunk and transpose a flat array into rows with a specific number of columns

How to implement placeholder in a php file for moodle plugin?

No result using makeStyles Material UI in react 18

Increase value by 1 on button click

Calculating Median of an array in PHP

About Contact Privacy policy Terms and conditions