Don't know where I am going wrong, but the icon just doesn't change.
$( ".inner-switch" ).on("click", function() {
if( $( "body" ).hasClass( "dark" )) {
$( "nav" ).removeClass( "dark-force" );
$( "body" ).removeClass( "dark" );
$(this).find("i").toggleClass("fas fa-moon");
} else {
$( "body" ).addClass( "dark" );
$( "nav" ).addClass( "dark-force" );
$(this).find("i").toggleClass("fas fa-sun");
}
});
.dark {
background-color: #222;
}
.dark-force * {
background-color: #222;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" />
<nav class="navbar">
<div class="hero-body">
<div class="container">
<div class="navbar-brand">
<a href="/">
<img src="{% static 'portfolio/Logo.png' %}" width=60>
</a>
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary is-rounded is-outlined">
<strong>Blog</strong>
</a>
</div>
</div>
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary is-rounded">
<strong>Say Hello!</strong>
</a>
</div>
</div>
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary is-rounded inner-switch">
<i class="fas fa-moon"></i>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
It does switch to dark mode, but the icon refuses to change from the moon(fas fa-moon). I'm new to javascript but fairly familiar with HTML and CSS. Any help is appreciated. Have a great and safe day! Thanks for reading!
You are nearly there and your code looks good but you need to use addClass and removeClass to switch fas fa icon from sun to moon and vice versa.
$(this).find("i").removeClass("fa-sun").addClass('fa-moon');
When you use toggleClass the existing is still there and new icon is not working as it suppose to.
Live Working Demo:
$(".inner-switch").on("click", function() {
if ($("body").hasClass("dark")) {
$("nav").removeClass("dark-force");
$("body").removeClass("dark");
$(this).find("i").removeClass("fa-sun").addClass('fa-moon');
} else {
$("body").addClass("dark");
$("nav").addClass("dark-force");
$(this).find("i").removeClass("fa-moon").addClass('fa-sun');
}
});
.dark {
background-color: #222;
}
.dark-force * {
background-color: #222;
}
.fa-sun {
color: white;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary is-rounded inner-switch is-outlined">
<i class="fas fa-moon"></i>
</a>
</div>
</div>
The problem is that you only toggle the sun and moon class every second time.
You need to toggle them both every time!
$(this).find("i").toggleClass("fa-moon").toggleClass("fa-sun");
FYI you don't need to toggle the fas class because you always need it. Also, you don't need to duplicate the code by putting this inside the if/else - as you need to toggle them both every time you click, you can just include this line once directly in the function.
Working example:
$(".inner-switch").on("click", function() {
// toggle moon and sun every time
$(this).find("i").toggleClass("fa-moon").toggleClass("fa-sun");
if ($("body").hasClass("dark")) {
$("nav").removeClass("dark-force");
$("body").removeClass("dark");
} else {
$("body").addClass("dark");
$("nav").addClass("dark-force");
}
});
.dark {
background-color: #222;
}
.dark-force * {
background-color: #222;
}
.button {
font-size: 3em;
color: #f00
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" />
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary is-rounded inner-switch is-outlined">
<i class="fas fa-moon"></i>
</a>
</div>
</div>
You also need to toggle the font color when you toggle the background color.
$("#lightswitch i").click(function() {
var isDark = $("body").is(".dark");
$("body").toggleClass("dark", !isDark);
$(this).toggleClass("fa-moon", isDark).toggleClass("fa-sun", !isDark);
});
body.dark {
background-color: #222;
color: white;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" />
<body>
<div class="navbar-item">
<div class="buttons">
<a id="lightswitch" class="button is-primary is-rounded inner-switch is-outlined">
<i class="fas fa-moon"></i>
</a>
</div>
</div>
</body>
Related
I am relatively new to Sass so apologies if the answer to this question is straightforward. I am building a navbar component and would like to style the entire navbar (.main-header) when hovering over specific icons (.navbar-links and .navbar-title). So far, I have tried setting the .main-header element to a variable ($h: &) as well as using #at-root to no avail. Any and all suggestions would be much appreciated.
Example of the behavior I am looking for:
.navbar-links:hover
results in
.main-header{
background: red;
}
code:
<nav className='main-header'>
<div className='navbar-title'>
<a href='/blog/home'>
<h2 className='navbar-title-text'>REVIEWS</h2>
</a>
</div>
<ul className='navbar-links'>
<li className='navbar-item'>
<a href='/blog/home'>
<FaHome className='navbar-icon' />
</a>
</li>
<li className='navbar-item'>
<a href='/blog/television'>
<FaTv className='navbar-icon' />
<div className='navbar-text'>TELEVISION</div>
</a>
</li>
</ul>
</nav>
You can use pointer-events: none; at the header and set the children to pointer-events: auto; so you can manage it with hover like this:
.main-header {
pointer-events: none;
}
.main-header:hover {
background-color: red;
}
.navbar-item {
pointer-events: auto;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<nav class='main-header'>
<div className='navbar-title'>
<a href='/blog/home'>
<h2 className='navbar-title-text'>REVIEWS</h2>
</a>
</div>
<ul className='navbar-links'>
<li className='navbar-item'>
<a href='/blog/home'>
<FaHome className='navbar-icon' />
</a>
</li>
<li class='navbar-item'>
<a href='/blog/television'>
<FaTv className='navbar-icon' />
<div className='navbar-text'>TELEVISION</div>
</a>
</li>
</ul>
</nav>
This question already has answers here:
Event binding on dynamically created elements?
(23 answers)
Closed 2 years ago.
I have the following snippet
$( "#diner_option" ).click(function( event ) {
event.preventDefault();
console.log('ok')
});
$( "#change" ).click(function( event ) {
var add_html = "<div id='diner_div' class='col-md-3 mx-auto planning_recipe_card'><a href='recipes_details.php?recipeid=1'><div class='card card_recipes'><i id='diner_option' class='fas fa-cog recipe_option'></i><img class='img_recipe scard-img-top simg-fluid' src='https://fr.chatelaine.com/wp-content/uploads/0001/01/salade-tiede-courgettes-grillees-10797.jpg' alt='salade tiede de courgettes'><div class='card-body card_body_recipe'><h5 class='card-title'>salade tiede de courgettes</h5></div></div></div></a></div>"
$("#diner_div").replaceWith(add_html)
console.log('changed');
});
.recipe_option{
position: absolute;
padding: 15px;
top: 0;
right: 0;
background: #353b43;
border-bottom-left-radius: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<button id="change">Change</button>
<div id="diner_div" class="col-md-3 mx-auto planning_recipe_card">
<a href="recipes_details.php?recipeid=1">
<div class="card card_recipes">
<i id="diner_option" class="fas fa-cog recipe_option"></i>
<img class="img_recipe scard-img-top simg-fluid" src="https://fr.chatelaine.com/wp-content/uploads/0001/01/salade-tiede-courgettes-grillees-10797.jpg" alt="salade tiede de courgettes">
<div class="card-body card_body_recipe">
<h5 class="card-title">salade tiede de courgettes</h5>
</div>
</div>
</a>
</div>
When I click on cog icon, I get in the console the message ok which means it worked as intended. But when I click on the change button to refresh the dom and click on the cog, the event.preventDefault(); function doesn't work. The cog works like a link then.
I would like to be able to reload the dom and the cog icon still work (which means, shows the ok message)
You have to rebind your click event to the new element that replaces your old cog. Call your jquery bind again.
$( "#diner_option" ).click(function( event ) {
event.preventDefault();
console.log('ok')
});
$( "#change" ).click(function( event ) {
var add_html = "<div id='diner_div' class='col-md-3 mx-auto planning_recipe_card'><a href='recipes_details.php?recipeid=1'><div class='card card_recipes'><i id='diner_option' class='fas fa-cog recipe_option'></i><img class='img_recipe scard-img-top simg-fluid' src='https://fr.chatelaine.com/wp-content/uploads/0001/01/salade-tiede-courgettes-grillees-10797.jpg' alt='salade tiede de courgettes'><div class='card-body card_body_recipe'><h5 class='card-title'>salade tiede de courgettes</h5></div></div></div></a></div>"
$("#diner_div").replaceWith(add_html);
$( "#diner_option" ).click(function( event ) {
event.preventDefault();
console.log('ok')
});
console.log('changed');
});
.recipe_option{
position: absolute;
padding: 15px;
top: 0;
right: 0;
background: #353b43;
border-bottom-left-radius: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<button id="change">Change</button>
<div id="diner_div" class="col-md-3 mx-auto planning_recipe_card">
<a href="recipes_details.php?recipeid=1">
<div class="card card_recipes">
<i id="diner_option" class="fas fa-cog recipe_option"></i>
<img class="img_recipe scard-img-top simg-fluid" src="https://fr.chatelaine.com/wp-content/uploads/0001/01/salade-tiede-courgettes-grillees-10797.jpg" alt="salade tiede de courgettes">
<div class="card-body card_body_recipe">
<h5 class="card-title">salade tiede de courgettes</h5>
</div>
</div>
</a>
</div>
I have the following div
<div class="col-sm" title="Device Name" id="titleDevice" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Name</div>
I am trying to show tooltip as below by pointing to the id of this element. This is working fine.
showTooltip("#titleDevice");
function showTooltip(idOfElement) {
$(idOfElement).hover(function() {
$(idOfElement).tooltip('show');
});
}
My issue is, in the page, sometimes there will be many such div which are dynamically generated. For that case, this selecting by id will not work and thus I tried selecting by class.
Example of such scenario with some number of div as below
<form method="post" id="qaForm">
<div class="card" style="background-color:white; color: white; position: relative; border-color: black; !important ">
<div class="card-body">
<div class="row">
<div class="col-sm" title="Device Name" class="titleDevice" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Name</div>
<div class="col-sm" title="second" class="second" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Second</div>
<div class="col-sm" title="third" class="third" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i>third</div>
</div>
</div>
</form>
showTooltip(".titleDevice");
function showTooltip(classOfElement) {
$(classOfElement).hover(function() {
$(classOfElement).tooltip('show');
});
}
Then used the same JQuery function. But when I hover over to one div, all the other div also showing the tooltip at the same time. Does anyone know how to solve this problem?
To show the tooltip for only that particular element, use this keyword
showTooltip(".titleDevice");
function showTooltip(idOfElement) {
$(idOfElement).hover(function() {
$(this).tooltip('show'); // Use 'this' here
});
}
If you want tooltip for dynamically generated div then use only
$(document).tooltip();
This will work for all div. You need not include the hover method.
You can preview below code:
$(document).tooltip();
//for dynamically add
$(document).on('click', '#add', function(){
$('#div').html('<div class="col-sm" title="Mobile Name" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Name</div>');
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<div class="col-sm" title="Device Name" id="titleDevice" data-toggle="tooltip" data-placement="bottom"><i class="fab fa-500px"></i> Name</div>
<hr />
<button id="add">Add New</button>
<hr />
<div id="div"></div>
I am using Bootstrap 3 tooltip but on one page i want to increase the size of them.
I don't want to affect the rest of the site.
I have tried the following code but it doesn't work so i was wondering if i have the syntax wrong or something.
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
});
.dashboard+.tooltip>.tooltip-inner {
max-width: 350px;
width: 350px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="row">
<div class="col-xs-12 col-md-7">
<p>This week:</p>
</div>
<div class="col-xs-12 col-md-4">
<p id="extTotalThisWk" class="dashboard" data-html="true" data-toggle="tooltip" data-placement="bottom" style="cursor: pointer" data-original-title="
<span class='text-left'>
<p style='padding-top: 5px'>This total number is made up from:</p>
<ul style='padding-bottom: 5px'>
<li>Added this week - Deleted this week</li>
</ul>
</span>">123</p>
</div>
<div class="hidden-xs col-md-1"></div>
</div>
I have also tried it without the +.tooltip in the CSS but it still doesn't apply it.
Also i have tried the following but still didn't work
<span class='text-left' style='max-width: 350px; width: 350px;'>
Obviously if i just use .tooltip-inner it works but this affects the whole site which i don't want to do.
If it is about selecting only that tooltip inside #extTotalThisWk, then you can use the id as a selector .
#extTotalThisWk + .tooltip > .tooltip-inner
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
});
#extTotalThisWk + .tooltip > .tooltip-inner {
max-width: 350px;
width: 350px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<p id="extTotalThisWk" class="dashboard" data-html="true" data-toggle="tooltip" data-placement="bottom" style="cursor: pointer" data-original-title="
<span class='text-left' >
<p>This total is:</p>
<div>Added this week - Deleted this week</div>
</span>">
123</p>
<p id="extTotalThisWkBis" class="dashboard" data-html="true" data-toggle="tooltip" data-placement="bottom" style="cursor: pointer" data-original-title="
<span class='text-left' >
<p>This total is:</p>
<div>Added this week - Deleted this week</div>
</span>">
another one , another id</p>
It is about
https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. Specificity is based on the matching rules which are composed of different sorts of CSS selectors.
You can wrap your code inside a div and can use > selector from parent class.Make sure that span elements are inline, so set them to block and give the style to it. Below is the working snippet
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
});
.main-holder>.tooltip>.tooltip-inner {
max-width: 500px;
text-align: center
}
span.text-left {
display: block;
width: 400px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="main-holder">
<p id="extTotalThisWk" class="dashboard" data-html="true" data-toggle="tooltip" data-placement="bottom" style="cursor: pointer" data-original-title="
<span class='text-left'>
<p>This total is:</p>
<div>Added this week - Deleted this week</div>
</span>">
123</p>
</div>
As I'm designing my node.js application, I'm having trouble figuring out why my anchor links are not working/not clickable. The code itself was working fine before I designed the app. Is there a CSS property I need to configure to fix this? This is for the .player ul li links.
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Bree+Serif' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/style.css">
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Indie+Flower' rel='stylesheet' type='text/css'>
<script src="http://connect.soundcloud.com/sdk.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> -->
<meta charset="UTF-8">
<title>Open Mic Chatroom</title>
</head>
<header>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<!-- <a class="navbar-brand" href="#">
<img alt="Brand" src="...">
</a> -->
<h1>OpenMic</h1>
</div>
</div>
</nav>
</header>
<body>
<div class="container">
<div class="row">
<div class="musicians col-sm-3 col-md-3">
<!-- <div class="musicians col-sm-6 col-md-4"> -->
<!-- <div class="col-sm-6 col-md-4"> -->
<!-- <div class="thumbnail musicians-box"> -->
<!-- <img src="..." alt="..."> -->
<div class="caption">
<h2>Musicians Online</h2>
<p>
<div id="chatters">
</div>
</p>
<!-- <p>Button Button</p> -->
<!-- </div> -->
</div>
</div>
<div class="chatroom col-sm-8 col-md-8">
<!-- <div class="chatroom col-sm-6 col-md-4">
--><!-- <div class="col-sm-6 col-md-4">-->
<!-- <div class="thumbnail chatroom-box"> -->
<!-- <img src="..." alt="..."> -->
<div class="caption">
<h2>Messages</h2>
<div id="messagesContainer"></div>
<!-- </div> -->
</div>
<form action="" id="chat_form">
<input id="info" autocomplete="off" />
<input type="submit" value="Submit">
</form>
</div>
</div>
</div>
<!-- <h3>Messages</h3>
<div id="messagesContainer"></div>
<form action="" id="chat_form">
<input id="info" autocomplete="off" />
<input type="submit" value="Submit">
</form> -->
<!-- SoundCloud Recording Feature -->
<div class="row player">
<div class="soundcloud-player">
<ul>
<div id="player">
<!-- <button type="button" id="startRecording" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-record" aria-hidden="true"></span>
</button> -->
<li id="startRecording">Start Recording</li>
</div>
<!-- <button type="button" id="stopRecording" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-stop" aria-hidden="true"></span>
</button> -->
<li id="stopRecording">Stop Recording</li>
<!-- <button type="button" id="playBack" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-play" aria-hidden="true"></span>
</button> -->
<li id="playBack">Play Recorded Sound</li>
<!-- <button type="button" id="upload" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-open" aria-hidden="true"></span>
</button> -->
<li id="upload">Upload</li>
</ul>
<p class="status"></p>
<div class="audioplayer">
</div>
</div>
</div>
<!-- <script src="/socket.io/socket.io.js"></script> -->
</div>
<script>
$(document).ready(function() {
var trackUrl;
//establish connection
var socket = io.connect('http://localhost:3000');
$('#chat_form').on('submit', function (e) {
e.preventDefault();
var message = $('#info').val();
socket.emit('messages', message);
$('#info').val('');
});
socket.on('messages', function (data) {
console.log("new message received");
$('#messagesContainer').append(data);
$('#messagesContainer').append('<br>');
// insertMessage(data);
});
socket.on('add_chatter', function (name) {
var chatter = $('<li>' + name + '</li>').data('name', name);
$('#chatters').append(chatter);
});
// //Embed SoundCloud player in the chat
// socket.on('track', function (track) {
// console.log("new track", track);
// SC.oEmbed(track, {auto_play: true}, function (oEmbed) {
// console.log('oEmbed response: ' + oEmbed);
// });
// SC.stream(track, function (sound) {
// console.log("streaming", sound);
// sound.play();
// });
// // socket.on('remove chatter', function (name) {
// // $('#chatters li[data-name=]' + name + ']').remove();
// });
//SOUNDCLOUD RECORDING FEATURE
function updateTimer(ms) {
// update the timer text. Used when user is recording
$('.status').text(SC.Helper.millisecondsToHMS(ms));
}
//Connecting with SoundCloud
console.log("calling SoundCloud initialize");
SC.initialize({
client_id: "976d99c7318c9b11fdbb3f9968d79430",
redirect_uri: "http://localhost:3000/auth/soundcloud/callback"
});
SC.connect(function() {
SC.record({
start: function() {
window.setTimeout(function() {
SC.recordStop();
SC.recordUpload({
track: { title: 'This is my sound' }
});
}, 5000);
}
});
//Adds SoundCloud username to chat app
console.log("connected to SoundCloud");
SC.get('/me', function(me) {
console.log("me", me);
socket.emit('join', me.username);
});
// SC.get('/me/tracks', {}, function(tracks) {
// var myTracks = $("<div>");
// var heading = $("<h1>").text("Your tracks");
// var list = $("<ul>");
// tracks.forEach(function (single) {
// var listItem = $("<li>").text(single.permalink);
// listItem.on("click", function () {
// SC.oEmbed(single.permalink_url, {
// auto_play: true
// }, function(oEmbed) {
// console.log("oEmbed", oEmbed);
// $('.status').html(oEmbed.html);
// });
// });
// list.append(listItem);
// });
// $("body").append(myTracks.append(heading, list));
// });
// username = prompt("What is your username?");
// socket.emit('join', username);
// });
//Start recording link
$('#startRecording a').click(function (e) {
$('#startRecording').hide();
$('#stopRecording').show();
e.preventDefault();
SC.record({
progress: function(ms, avgPeak) {
updateTimer(ms);
}
});
});
//Stop Recording link
$('#stopRecording a').click(function (e) {
e.preventDefault();
$('#stopRecording').hide();
$('#playBack').show();
$('upload').show();
SC.recordStop();
});
//Playback recording link
$('#playBack a').click(function (e) {
e.preventDefault();
updateTimer(0);
SC.recordPlay({
progress: function (ms) {
updateTimer(ms);
}
});
});
//Uploaded SoundCloud Track after recorded
$('#upload').click(function (e) {
e.preventDefault();
SC.connect({
connected: function() {
console.log("CONNECTED");
$('.status').html("Uploading...");
SC.recordUpload({
track: {
title: 'My Recording',
sharing: 'public'
}
},
//When uploaded track, provides link user, but not everyone
function (track) {
// console.log("TRACK", track);
setTimeout(function () {
SC.oEmbed(track.permalink_url, {auto_play: true}, function(oEmbed) {
console.log("THIS IS oEMBED", oEmbed);
// console.log(oEmbed.html);
socket.emit('messages', oEmbed.html );
$('.status').html(oEmbed.html);
});
}, 8000);
// $('.status').html("Uploaded: <a href='" + track.permalink_url + "'>" + track.permalink_url + "</a>");
});
}
});
});
});
});
</script>
</body>
</html>
CSS:
body {
background: url('microphone.svg') no-repeat center center fixed;
background-position: 4% 100%;
}
h1, h2, h3 {
font-family: 'Bree Serif', serif;
}
body {
font-family: 'Open Sans', sans-serif;
}
h1 {
color: white;
padding-left: 5%;
padding-bottom: 5%;
letter-spacing: 4px;
}
.navbar-default {
background-color: #000000;
/* background-image: url('SoundWave.jpg');
background-position: center;
opacity: 0.8;*/
}
input, button, select, textarea {
line-height: 3;
}
.chatroom, .musicians {
border-style: solid;
border-radius: 6%;
border-color: black;
margin-left: 20px;
height: 500px;
background-color: #F2F2F2;
opacity: 0.8;
}
.musicians {
height: fixed;
}
input#info {
margin: 47% 1%;
width: 656px;
border-radius: 10%;
}
.visualSoundContainer__teaser {
height: 100px;
}
.row {
padding-top: 2%;
}
.player {
text-align: center;
}
.player ul li {
z-index: 30;
}
Comment the margin property. It is cover the section. you can check it on firebug while selecting the anchor element.
input#info {
/*margin: 47% 1%;*/
width: 656px;
border-radius: 10%;
}
Working link: http://jsfiddle.net/95yz0h63/
add css
a{
cursor:pointer;
}