I'm trying to make an element draggable using JQuery
I tried this but it didn't work because the scripts are not working and it looks like there isn't a link. Here is my code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.1.custom.min.js"></script>
<script>
$( function() {
$( "#drag" ).draggable();
});
</script>
<style>
#drag {
width: 100px;
height: 100px;
cursor: all-scroll;
background-color: aqua;
}
</style>
</head>
<body>
<div id="drag"></div>
</body>
</html>
it looks like you did not have the files js/jquery-1.3.2.min.js and js/jquery-ui-1.7.1.custom.min.js present in your file system. I have replaced the files with CDN.
Find CDN here:
https://cdnjs.com/libraries/jquery
https://cdnjs.com/libraries/jqueryui
It doesn't necessarily need to be written after page load. But it can increase initial load time in some cases!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" integrity="sha512-uto9mlQzrs59VwILcLiRYeLKPPbS/bT71da/OEBYEwcdNUk8jYIy+D176RYoop1Da+f9mvkYrmj5MCLZWEtQuA==" crossorigin="anonymous"></script></script>
<script>
$( function() {
$( "#drag" ).draggable();
});
</script>
<style>
#drag {
width: 100px;
height: 100px;
cursor: all-scroll;
background-color: aqua;
}
</style>
</head>
<body>
<div id="drag"></div>
</body>
</html>
The order in your code plays an important role in things .. You need to load your scripts AFTER the DOM loads .. Also -- Religiously view your DevTools F12 -- The console gives vital information about DOM elements not being found, loaded etc etc ..
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#drag {
width: 100px;
height: 100px;
cursor: all-scroll;
background-color: aqua;
}
</style>
</head>
<body>
<div id="drag"></div>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>
<script
src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"
integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E="
crossorigin="anonymous"></script>
<script>
$( function() {
$( "#drag" ).draggable();
});
</script>
</body>
</html>
Related
I was curious how I can add this type of textarea to my CSHTML page (MVC .NetCore)
You can use Summernote.
I am currently using one in my project
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/summernote#0.8.18/dist/summernote-lite.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote#0.8.18/dist/summernote-lite.min.js"></script>
</head>
<body>
<textarea asp-for="Description" id="summernote"></textarea>
<script>
$('#summernote').summernote({
placeholder: 'Description goes here....',
height:'25vh',
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture']],
['view', ['fullscreen', 'codeview', 'help']]
]
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue js 01</title>
</head>
<body>
<div >
<h1 id="message" #click="update">{{message}}</h1>
</div>
<script src="https://unpkg.com/vue#next"></script>
<script>
let app = Vue.createApp({
data(){
return {
message:'hai welcome to vue 3!',
}
},
methods:{
update(){
this.message='Changed'
}
}
})
app.mount("#message")
</script>
</body>
</html>
why this is not working when click on h1 tag
when I am clicking this h1 tag it is not working. but if it is inside a <div> it will be work moving it id to this div
I'm working on a boilerplate with 3 fallbacks: jQuery, Bootstrap.js and Bootstrap.css. The first 2 are working fine, but I can't make the css fallback work properly (I'm using this reference: Should I use Bootstrap from CDN or make a copy on my server?)
Here's the markup:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
<meta name="description" content="" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/{{BOOTSTRAP_VERSION}}/css/bootstrap.min.css" rel="stylesheet" integrity="{{BOOTSTRAP_SRI_HASH}}" crossorigin="anonymous">
<link rel="stylesheet" href="css/main.min.css" />
</head>
<body>
<h1>Hello World!</h1>
</body>
<script src="https://code.jquery.com/jquery-{{JQUERY_VERSION}}.min.js" integrity="{{JQUERY_SRI_HASH}}" crossorigin="anonymous"></script>
<script>
window.jQuery || document.write('<script src="js/vendor/jquery/dist/jquery/jquery.min.js"><\/script>')
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/{{BOOTSTRAP_VERSION}}/js/bootstrap.min.js" integrity="{{BOOTSTRAP_SRI_HASH}}" crossorigin="anonymous"></script>
<div class="hidden" id="bootstrapCssTest"></div>
<script>
if (typeof($.fn.modal) === 'undefined') {
document.write('<script src="/js/vendor/bootstrap/dist/js/bootstrap.min.js"><\/script>');
}
</script>
<script>
$(function() {
if ($('#bootstrapCssTest').is('visible')) {
$('head').prepend('<link rel="stylesheet" href="/js/vendor/bootstrap/dist/css/bootstrap.min.css">');
}
});
</script>
<script src="js/bundle.min.js"></script>
</html>
You mistyped the selector. You need :visible, not visible
$(function() {
if ($('#bootstrapCssTest').is(':visible')) {
$('head').prepend('<link rel="stylesheet" href="/js/vendor/bootstrap/dist/css/bootstrap.min.css">');
}
})
I am trying to make a gallery on my webpage using magnific popup but I can't get the image to show up in a popup it only shows up in a separate tab. How can I get it to show up in gallery view and enabled cycling through all the images in the web page's gallery? In addition, how can I change the size of the lightbox being displayed and the size of the thumbnail.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Magnific Popup core CSS file -->
<link rel="stylesheet" href="magnific-popup/magnific-popup.css">
<!-- Magnific Popup core JS file -->
<script src="magnific-popup/jquery.magnific-popup.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/style.css">
<style type="text/css">
.modal-dialog {}
.thumbnail {margin-bottom:6px; height: 280px;}
.carousel-control.left,.carousel-control.right{
background-image:none;
margin-top:10%;
width:5%;
}
#open-popup {padding:20px}
.white-popup {
position: relative;
background: #FFF;
padding: 40px;
width: auto;
max-width: 200px;
margin: 20px auto;
text-align: center;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('.image-link').magnificPopup({type:'image'});
$('.test-popup-link').magnificPopup({
type: 'image'
// other options
});
});
</script>
</head>
<body>
<div id="main" role="main">
<br />
<br />
<br />
<div class="parent-container">
Open popup 1
Open popup 2
Open popup 3
</div>
</body>
</html>
The problem is with your HTML mark up !!
Open popup 1 This won't work.
<a class="test-popup-link" href="path-to-image-1.jpg">Open popup 2</a>
But this will work.
Check Codepen
I have a simple polymer app:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta http-equiv="x-ua-compatible" content="IE=10" >
<script type="text/javascript" src="components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="components/font-roboto/roboto.html">
<link rel="import" href="viewer-app.html">
<style>
html,body {
background-color: #fff;
font-family: 'RobotoDraft', sans-serif;
}
</style>
</head>
<body fullbleed vertical layout unresolved>
<template is="auto-binding">
<viewer-app fit></viewer-app>
</template>
</body>
the custom element 'viewer-app' does not even show up in f12 tools. I'm not getting any errors at all.
How do I get this to work?