That you should work, but I would probably change it to this:
$(".myClass").css("width",$(".myClass").parent().css("width"));
You may be able to use this instead of the second $(".myClass") , but you will have to check this.
Keep in mind that he does not change the class itself. It changes the width of any element that uses this class.
UPDATE:
If you intend to do any calculations with the width of the parent, you should probably stick to your original method. I like css when you apply styles as is, but this is a personal preference. If you make any modifications to the parent value, then width is probably better.
From the width documentation:
It is recommended to use the .width () method when the width of an element should be used in mathematical calculation.
source share