JavaScript Increase element width by percentage using jQuery increase element width javascript,increase element width css,increase element

This answer by Varinder works well but I would like to get the element width which is set in pixels and increase it by 10%.

$(window).load(function() {
    $(".ml").each(function() { // this is kindof sugary way of doing for loop over array of elements - which is $(".ml")
         var $this = $(this); // the current jQueried .ml element
         var currentWidth = $this.width(); // get width of current element, width is a jQuery method: https://api.jquery.com/width/
         var newWidth = currentWidth + 5; // increment the width
         $this.width(newWidth); // pass in the new width as the parameter.
    });
});
Answer:1

I think there's several ways to do that, try ;

 var currentWidth = $this.width();

 var newWidth = currentWidth * 1.1; //increment by 10%
 //OR
 var newWidth = currentWidth + ( currentWidth * 10) / 100; //increment by 10%

Hope this helps.

Answer:2

You just have to set the new width to the old width + 10% of the old width:

var newWidth = currentWidth + (currentWidth * 0.1);
Answer:3

I am working on a project in which I want to play different types of news channels live on my website Here is my code in which I am trying to play the channels <div class="video_box"> <...

I am working on a project in which I want to play different types of news channels live on my website Here is my code in which I am trying to play the channels <div class="video_box"> <...

  1. live channel streaming services
  2. live channel streaming free
  3. live channel streaming reddit
  4. live channel streaming golf
  5. live channel streaming app
  6. live channel streaming india
  7. live channel streaming online
  8. live streaming channel 5

I have this HTML code with pre-written message. My goal is to highlight text between [quote] [/quote] in a yellow background once I focus/click on the text area. <textarea> This is a test ...

I have this HTML code with pre-written message. My goal is to highlight text between [quote] [/quote] in a yellow background once I focus/click on the text area. <textarea> This is a test ...

  1. javascript find and highlight text on page
  2. javascript window.find highlight all
  3. javascript find and highlight text
  4. javascript find string and highlight
  5. javascript find on page highlight
  6. find and highlight javascript

Scenario I am having a functionality in my project in which we have to add a note in a section and then it can be moved to the other sections. It is a sort of task tracking. I am able to add a note ...

Scenario I am having a functionality in my project in which we have to add a note in a section and then it can be moved to the other sections. It is a sort of task tracking. I am able to add a note ...

I Have a jquery export table to excel code. But the problem is that it changes the value is export file of xls. my table td has a value 810101E001 when I export it it changes the value like 8.10E+06. ...

I Have a jquery export table to excel code. But the problem is that it changes the value is export file of xls. my table td has a value 810101E001 when I export it it changes the value like 8.10E+06. ...

  1. jquery export table to csv
  2. jquery export table to excel
  3. jquery export table to pdf
  4. jquery export table to xlsx
  5. jquery export table to excel plugin
  6. jquery export table to excel xlsx
  7. jquery export table to pdf plugin
  8. jquery export table
  9. jquery export table to excel utf-8
  10. jquery export table data to excel
  11. jquery export table data with images to excel
  12. jquery export table to csv file
  13. jquery export table to xls
  14. jquery export table to excel and pdf
  15. jquery export table to word
  16. jquery export table to xml
  17. jquery export table to json
  18. jquery export table to excel jsfiddle
  19. jquery export table html
  20. jquery table export to excel example