Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js dom after selectors

//set an attribute and get it in js and set value
p:before {
    content: attr(data-before);
    color: red;
    cursor: pointer;
}

$('p').on('click', function () {
    $(this).attr('data-before','bar');
});
// or

//Add/remove a predetermined class

p:before {
    content: "foo";
}
p.special:before {
    content: "bar";
}


//or 

var str = "bar";
document.styleSheets[0].addRule('p.special:before','content: "'+str+'";');

//read ::after,::before

var str = window.getComputedStyle(document.querySelector('p'), ':before') 
           .getPropertyValue('content');
Comment

js dom after selectors

var str = "bar";

document.styleSheets[0].addRule('p:before', 'content: attr(data-before);');

$('p').on('click', function () {
    $(this).attr('data-before', str);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: ES2022 - Top-level await modules 
Javascript :: Private slots are new and can be created via Instance private fields 
Javascript :: json serializable snake case 
Javascript :: mettre en commentaire vscode 
Javascript :: js wrap a function pass parameters to function 
Javascript :: map and get last child in js 
Javascript :: protoypes in constructor functions in javascript 
Javascript :: many button with many action in javascript 
Javascript :: how to use window.alert in javascript 
Javascript :: javascript camel case to words 
Javascript :: last iteration is for loop js ES6 
Javascript :: console.dir vs console.log 
Javascript :: Arrow functions by Codeacademy 
Javascript :: javascript array table append loop 
Javascript :: Block Alignment Toolbar Using ES5 in Wordpress 
Javascript :: javascript extrsct object 
Javascript :: format file using jq input curl 
Javascript :: vscode react debug chrome profile 
Javascript :: itreating string js 
Javascript :: random number between 0 and 50 then round to a whole number 
Javascript :: btn click on click file javascript 
Javascript :: how to change elemen size in js when custom page width changed 
Javascript :: CalendarTriggerBuilder 
Javascript :: detect nodejs 
Javascript :: filter list of array if not true return default array 
Javascript :: xmlhttprequest set route params 
Javascript :: async loop with mongoose 
Javascript :: reading data from link in javascript 
Javascript :: gsheet get cell background color 
Javascript :: save file as get dimensions puppeteer js 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =