0

I'm trying to set a value of a css property with a calculated variable value.

I have two classes .v-table__overflow and .v-datatable__actions. I want to get the width value of .v-table__overflow and set this value in .v-datatable__actions as the value of width of this class.

I'm getting this error:

Uncaught TypeError: Cannot read property 'setProperty' of undefined

var dtoverflow = document.querySelector('.v-table__overflow')
const style4 =  getComputedStyle(dtoverflow);
var dtoverflowWidth = style4.width 

var dtActions = document.querySelector('.v-datatable__actions') 
const style5 =  getComputedStyle(dtActions); 
var dtActionsWidth = style5.width;

dtActionsWidth.style.setProperty('width', '--dtoverflowWidth');
2
  • It looks like dtActionsWidth is the width value from the computed styles of dtActions. The variable dtActionsWidth has no style property. Maybe you want dtActions.style.setProperty(...)? Commented Jun 26, 2019 at 5:30
  • its a vuetiify app - using a vue.js framework for frontend Commented Jun 26, 2019 at 5:34

1 Answer 1

1

Try this way

var dtoverflow = document.querySelector('.v-table__overflow')
var dtoverflowWidth = getComputedStyle(dtoverflow).width;

var dtActions = document.querySelector('.v-datatable__actions') 
var dtActionsWidth = getComputedStyle(dtActions).width;

dtActions.style.width = dtoverflowWidth;

You also had a typo with using dtActionsWidth instead of dtActions in the last line which threw the error.

Sign up to request clarification or add additional context in comments.

1 Comment

@showdev The code had a typo with using dtActionsWidth instead of dtActions in the last line which threw the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.