jquery

get HTML of dynamically created table rows

自作多情 提交于 2021-01-28 08:43:30
问题 This question has been asked numerous times but never really answered specifically without the use of a third party application. I have dynamically created rows in a table that already has 2 static rows. The rows are created fine and appended to the :last and I can get/pull/push the .val .text ect... but cannot get the full html output as seen in 'view page source' of most browsers. Even examples like: document.getElementsByTagName('html')[0].innerHTML; don't retrieve the dynamically created

Bootstrap 4 Smart Scroll

时间秒杀一切 提交于 2021-01-28 08:41:07
问题 I'm using this basic tutorial to show/hide a standard BS4 navbar on scroll, and it works great for desktop. However, on mobile the navbar is acting a little strange when scrolling down, then going back to the top. Once back to the top, the navbar hides again. I suspect the issue has something to do with scrollTop() but can't seem to troubleshoot this one. Here's my JS: if ($('.smart-scroll').length > 0) { // check if element exists var last_scroll_top = 0; $(window).on('scroll', function() {

Showing dynamic links inside a table

我怕爱的太早我们不能终老 提交于 2021-01-28 08:40:05
问题 In jquery, how can I show a link that is generated on the fly inside a table? I will have the link stored in my database, but I want it to be shown by a name and then take me to the correct link accordingly. I have an array of strings like [ {Name1:Link1} ] stored, and I want it to be shown inside the table as Name1 linking to Link1 . Please tell me how to do so. 回答1: You need to store them in a (object) map instead of an array. var linksMap = { 'google': 'http://google.com', 'stackoverflow':

how get anchor tag url hash values in jquery?

ⅰ亾dé卋堺 提交于 2021-01-28 08:39:06
问题 How to get this url anchor tag hash values? i am trying this code but this shows undefined. HTML & Jquery 3.2: $(function(){ // get current url hash values. var current = window.location.hash; $('#navbarSupportedContent ul li a').each(function(){ var $this = $(this); alert($this.hash); }); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class=

Uncaught ReferenceError: jQuery is not defined VueJS Parcel

偶尔善良 提交于 2021-01-28 08:32:22
问题 I have this: import jQuery from 'jquery' import HSCore from './components/assets/js/hs.core.js' Yet I still get this: Uncaught ReferenceError: jQuery is not defined at Object.parcelRequire.client/components/assets/js/hs.core.js (hs.core.js:177) Why 😑 import jQuery from 'jquery' does actually import jQuery (via console.log(jQuery) ), but my other JS file is having problems accessing it(?). This is in a Vue file using Parcel loader. hs.core.js file: (function ($) { ... })(jQuery); //<-- line

POST with Jquery and receive a response from Node.js

…衆ロ難τιáo~ 提交于 2021-01-28 08:20:58
问题 I'm trying to do something very simple, I want to do a POST with AJAX Jquery to a Node.js server and have the server return a response. My problem is that I can't get that answer from the server. If someone can help me, I will be very grateful. client.js $(document).ready(function(){ $("button").click(function(){ $.post("http://localhost:3333/vrp", { name: "Donald Duck", city: "Duckburg" }, function(data,status){ alert("Data: " + data + "\nStatus: " + status); //This section code doesn't

Why does my jQuery getJSON call (within Office.js (Excel js add-in)) return an error?

不打扰是莪最后的温柔 提交于 2021-01-28 08:16:27
问题 This javascript within an Office js add-in always fails when making a get request: function update() { Excel.run(function (ctx) { return ctx.sync() .then(function () { var company = $('#company').val(); var environment = $('#environment').val(); var apiUrl = "https://localhost:44321/api/Country"; var params = "company=" + company + "&environment=" + environment; $.getJSON(apiUrl, params) .done(function (result) { showNotification(result.length); }) .fail(function (xhr, status, error) { /

How to remotely simulate a dropdown selection

让人想犯罪 __ 提交于 2021-01-28 08:12:05
问题 I have several dropdown select menus where a selection of the first changes the options of the second and a selection on the second changes the options of the third, and so on. I would like to remotely simulate a change (i.e. without the user clicking in the select menu) in the dropdown menu which will activate the Javascript to set the next dropdown's options. Just setting the value of the select menu - document.getElementById('...').value='....' - does not stimulate the Javascript events on

How to use javascript promises ES6 instead of jQuery ajax call?

感情迁移 提交于 2021-01-28 08:11:47
问题 I was trying to understand how promises works in javascript but I didn't found clear info about this, I would like to know if it possible and it is so how to do this using promises instead this code (equivalent) $.ajax({ type: 'post', cache: false, url: 'myfile.php', data: { info: info }, datatype: 'json', success: function(response) { console.log(response); } }); I ask this because I want to use only javascript without any framework or plugins, I have no problem with the other new feautures

Get dynamically created element that was click javascript

青春壹個敷衍的年華 提交于 2021-01-28 08:10:48
问题 I'm trying to track what buttons users click via javascript/jquery. I have the following code $(document).on('click', '[data-tracker]', function( event ) { var target = event.target; var targetName = $(target).data('tracker'); console.log(targetName); }); <button data-tracker="test1">test1</button> <i data-tracker="test2">test2</i> <img data-tracker="test3"> At the moment this works as I want it to. When someone clicks on an element on the page that has the data-tracker attribute I log the