And I wanna apply a style to first element <h3> with .ctr-1 h3:first-child{ display:none; }, however, it will apply to all <h3>, I only want the first <h3> has this style.
Answer
:first-of-type and :nth-of-type() might be helpful here.
:first-of-type
The :first-of-type CSS represents the first element of its type among a group of sibling elements. See example below.
There is a console.log from Chrome webkit inspector. How to copy it directly?
Answer
Right-click an object in Chrome’s console and select Store as Global Variable from the context menu. It will return something like temp1 as the variable name.
Chrome also has a copy() method, so copy(temp1) in the console should copy that object to your clipboard.
I have a string called I have cats, dogs, and goats., and I want to replace to I have AA, BB, and CC..
How to make it happen only with one function?
Answer
If you only wanna it happen easily, just need one function to replace all of them.
1 2 3 4 5 6 7 8 9
var str = "I have cats, dogs, and goats"; var mapObj = { cats:"AA", dogs:"BB", goats:"CC" }; str = str.replace(/cat|dog|goat/gi, function(matched){ return mapObj[matched]; });