• 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

Laravel websockets AWS EC2 - Connection failed

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

How can I make Laravel return a custom error for a JSON REST API

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

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

how to hide previous markers when new markers added in google map javascript api

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

Exact alternate to mcrypt_encrypt in PHP 7.2

How to identify whether webp image is static or animated?

Limit login attempts in Laravel 5.7

Google Gmail API - How to login programatically?

Insert And Retrieve Data in MySQL with $.post Noob Question

Destroy session upon refresh

Merge key and value of array index [duplicate]

WooCommerce Additional Information - if empty, hide

About Contact Privacy policy Terms and conditions