• 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 submit a form when page loads using JavaScript?

Make Calculator - When Button clicked the No shows in Textbox.

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

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

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Symfony Error: "An exception has been thrown during the rendering of a template"

How to create a video stream from a single dynamic image in PHP

Combine array with same value and add other [duplicate]

Changing font color in javascript

Correct way to use LIKE '%{$var}%' with prepared statements?

How to keep value of selected value after form submission?

MOODLE: What does it mean to aggregate h5p assets?

php echo remove slashes from url [duplicate]

Check if a string contain multiple specific words

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

About Contact Privacy policy Terms and conditions