Web Development Articles

Page 796 of 801

JavaScript - Constructs a new array whose elements are the difference between consecutive elements of the input array

AmitDiwan
AmitDiwan
Updated on 15-Sep-2020 190 Views

Suppose, we have an array of numbers like this −const arr = [3, 5, 5, 23, 3, 5, 6, 43, 23, 7];We are required to write a function that takes in one such array and constructs another array whose elements are the difference between consecutive elements of the input array.For this array, the output will be −const output = [-2, 0, -18, 20, -2, -1, -37, 20, 16];ExampleFollowing is the code −const arr = [3, 5, 5, 23, 3, 5, 6, 43, 23, 7]; const consecutiveDifference = arr => {    const res = [];    for(let i = 0; ...

Read More

Calculate compound interest in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Sep-2020 6K+ Views

Compound Interest FormulaCompound interest is calculated using the following formula −CI = P*(1 + R/n) (nt) – PHere, P is the principal amount.R is the annual interest rate.t is the time the money is invested or borrowed for.n is the number of times that interest is compounded per unit t, for example if interest is compounded monthly and t is in years then the value of n would be 12. If interest is compounded quarterly and t is in years then the value of n would be 4.We are required to write a JavaScript function that takes in principal, rate, ...

Read More

Should I use , , or for SVG files?

Swarali Sree
Swarali Sree
Updated on 26-Jun-2020 521 Views

To add SVG files, you can use , or element in HTML. Choose any one of them according to your requirement. Here’s how you can add SVG, elementUse the tag for images without interaction.The disadvantage is you cannot manipulate images with JavaScript. elementThe element is used to define an embedded object within an HTML document. Use it to embed multimedia like audio, video, flash, etc in the web page.    Your browser does not support SVG elementThe tag wasn’t part of the HTML 4 specification and is new in HTML5. It validates in an HTML5 page.

Read More

How to use .svg files in a webpage?

Swarali Sree
Swarali Sree
Updated on 26-Jun-2020 770 Views

The svg files are Scalable Vector Graphics. You can add it to a web page using the , , or tag.The .svg file is to be referenced in the src attribute of the tag. Let’s see how to add it using the tag.You can try to run the following code to learn how to use .svg files in a web page. We have a smiley.svg file −           HTML SVG               Design          

Read More

Render ASP.NET TextBox as HTML5 Input type "Number

karthikeya Boyini
karthikeya Boyini
Updated on 25-Jun-2020 1K+ Views

To render ASP.NET TextBox as HTML5 input type “Number”, set type="number" directly on the textbox.Let us see an example of ASP.NET TextBox −You can also use the following dynamically created the control −TextBox tb = new TextBox(); tb.Attributes.Add("Type", "number");

Read More

What are Pure HTML export buttons in jQuery Data Table?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 24-Jun-2020 233 Views

jQuery Data Table provides export buttons with the help of which we can make a structure like the following −Export PDFExport CSVExport HTMLExport ExcelFor this, we need to write code −var tbl = $('#extable').DataTable({      dom: 'export',        buttons: [          {                 extend: 'collection',                 text: 'Export',                 buttons: [ 'csvHtml5', ' pdfHtml5', 'copyHtml5', 'excelHtml5' ]          }        ] });

Read More

How do I use jQuery effects?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Jun-2020 276 Views

For hiding and showing the div, you can use hide and show method.For hiding$('#id1').hide();For showing$('#id1').show();Example showhide                 $(document).ready(function () {          $('#btn1').click(function () {             $('#id1').hide();          });          $('#btn2').click(function () {             $('#id1').show();          });       });        I Am A Simple Paragraph    Hide    Show MethodDescriptionanimate()Runs a custom animation on the selected elementsclearQueue()Removes all remaining queued functions ...

Read More

Bootstrap 4 .border-secondary class

Alex Onsman
Alex Onsman
Updated on 16-Jun-2020 278 Views

Use the border-secondary class in Bootstrap 4 to add a gray border to an element.Set the border as −   Gray border I have styled our element as shown in the following code snippet − .test {   width: 200px;   height: 150px;   margin: 10px; } You can try to run the following code to implement the border-secondary class −ExampleLive Demo       Bootstrap Example                             .test {       width: 200px;       height: 150px;       margin: 10px;     }       Rectangle   Gray border

Read More

How to trim a string using $.trim() in jQuery?

Ricky Barnes
Ricky Barnes
Updated on 15-Jun-2020 3K+ Views

To trim a string in jQuery, use the trim() method. It removes the spaces from starting and end of the string. The sample string I am using has spaces − var myStr = " Hello World "; Use the trim() method, jQuery.trim(myStr); The following is an example to trim a string in jQuery − Example $(document).ready(function(){   $("#button1").click(function(){     var myStr = "   Hello World      ";     myStr = jQuery.trim(myStr);     alert(myStr);   }); }); Trim

Read More

How to include Bootstrap Plugins on a website

Arjun Thakur
Arjun Thakur
Updated on 15-Jun-2020 163 Views

To include Bootstrap plugins on a website, consider any of the below form −IndividuallyUsing Bootstrap's individual *.js files. Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs.Compiled (all at once)Using bootstrap.js or the minified bootstrap.min.js. Do not attempt to include both, as both bootstrap.js and bootstrap.min.js contain all plugins in a single file.

Read More
Showing 7951–7960 of 8,010 articles
« Prev 1 794 795 796 797 798 801 Next »
Advertisements