I wanna make like system that system suggest books to user with JQuery and user like it.
First, at index.php has 2 suggested book. And there is no problem. User can click Like Button. And new book is uploaded insted of liked book. But user can not click the button. The page can not connect functions.js page.
My codes is:
At index.php
<!-- Suggest book -->
<div class="book-box" id="<?php echo $book_id;?>" style="background: #fff;box-shadow: 0 0 1px 1px rgba(0,0,0,.2); min-height: 60px;margin-bottom: 10px!important;bg-444;" data-target="<?php echo $book_id;?>">
<img src="img/<?php echo $ki_image;?>" style="width:100%; height: 150px;padding:0;" alt="">
<div class="container-fluid" style="">
<div class="row" style="">
<div class="caption mt5 p5" style="">
<div class="col-md-12 p0"><strong style="color: #1198BF; cursor: pointer;"><?php echo min_val($book_name,40);?></strong></div>
<div class="col-md-6 mt10" style="font-size: 13px;color: #777;margin-right: 30px;padding: 0;">
<p>2 dostun - 500 nəfər buradadır</p>
</div>
<div class="join " style="margin-top: 10px;float: left;">
<button name="btn_book" class="suggested_join_book" style="font-size: 12px; border-color: #ccc; outline: none; border-radius: 2px; padding: 5px 7px; box-shadow: 0 0 1px 1px rgba(0,0,0,.3); border: none;" data-id="<?php echo $book_id;?>">Abunə ol</button>
</div>
</div>
</div>
</div>
</div>
<div class="clb"></div>
<!-- Finish SuggestBook -->
functions.js is:
$(".suggested_join_book").on("click",function(){
var book_id = $(this).data("id");
$.ajax({
type: "post",
url : "join_book.php",
data: {"book_id":book_id},
success: function(veri){
// $("[data-target="+book_id+"]").addClass('animated fadeOut');
$("[data-target="+book_id+"]").css('display','none');
// $("#"+book_id).load("ajax.php?bol=new_book");
$.ajax({
type: 'post',
url: 'ajax.php?bol=new_book_2',
data: {"userID":'15'},
success: function(arr){
$(".suggest").append(arr);
}
});
}
});
});
ajax.php is:
case "new_book_2":
$userID = $_POST['userID'];
foreach (new_book_2($userID) as $nb) {
$book_name = $nb["ki_name"];
$ki_image = $nb["ki_image"];
$book_id = $nb["ki_id"];
if($ki_image == ""){$ki_image = 'noprofile.jpg';}
?>
<!-- Suggest book -->
<div class="book-box " id="<?php echo $book_id;?>" style="background: #fff;min-height: 83px;margin-bottom: 10px!important;bg-444" data-target="<?php echo $book_id;?>">
<?php
?>
<img src="img/<?php echo $ki_image;?>" style="width:100%; height: 222px;padding:0;border-top-left-radius: 4px;border-top-right-radius: 4px;" alt="">
<div class="container-fluid" style="">
<div class="row" style="">
<div class="caption mt5 p5" style="">
<div class="col-md-12 p0"><strong style="color: #1198BF; cursor: pointer;"><?php echo min_val($book_name,40);?></strong></div>
<div class="col-md-7 mt10" style="font-size: 13px;color: #777;margin-right: 8px;padding: 0;">
<p>2 dostun - 500 nəfər buradadır</p>
</div>
<button name="btn_book sonradan" class="btn btn-primary join_book" data-id="<?php echo $book_id;?>">Abunə ol</button>
</div>
</div>
</div>
</div>
<div class="clb"></div>
<!-- Finish SuggestBook -->
<?php
}
break;
May be you include functions.js before your html tags. Put your click event into the jquery's ready method:
$(document).ready(function(){
$(".suggested_join_book").on("click",function(){
var book_id = $(this).data("id");
$.ajax({
type: "post",
url : "join_book.php",
data: {"book_id":book_id},
success: function(veri){
// $("[data-target="+book_id+"]").addClass('animated fadeOut');
$("[data-target="+book_id+"]").css('display','none');
// $("#"+book_id).load("ajax.php?bol=new_book");
$.ajax({
type: 'post',
url: 'ajax.php?bol=new_book_2',
data: {"userID":'15'},
success: function(arr){
$(".suggest").append(arr);
}
});
}
});
});
});
Related
This question already has answers here:
Using the context of the 'this' keyword with jQuery
(4 answers)
jQuery $(this) keyword
(6 answers)
Closed 3 years ago.
I am working on PHP to display a modal when I click on a hyperlink. I have got a problem with post the ID in ajax, because it will not fetch the id from the hyperlink to post it in ajax so I don't know why.
I have tried this but it didnt work:
var id = $(this).attr('autoid');
$.ajax({
type: 'POST',
url: "sendtest.php",
data: {autoid : id},
success: function(resultData)
{
alert(resultData)
}
here is the code:
<span style="font-size: 15px; color: #ccd5d9; float: left; margin-top: -1px">Send a test | <a name="autoid" id="autoid" href="/delete_id.php?id=<?php echo $autoid ?>"> Delete </a> | Copy to Draft | Settings</span>
<div id="contactModal" class="modal fade" style="margin-top: 12%;" tabindex="-1" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" style="height: 250px;">
<div class="modal-header" style="margin-bottom: 10px;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Send A Test Email</h3>
</div>
<div class="modal-body" style="height: 65%;">
<form action="" method="post">
<label class="label-control" value="">Send test message to email address:</label>
<?php
$html = '<select name="emails" id="emails" value="" style="width: 400px; margin-top: 10px; margin-bottom: 18px; margin-left: 60px;">';
$values = array('unknown', $_SESSION["email"]);
foreach($values as $v)
{
$selected = '';
if($v == 'unknown')
{
$title = '';
}else{
$title = $v;
}
if($v == $_SESSION["from"])
{
$selected = "selected";
}
$html .= "<option $selected value='$v'>$title</option>";
}
$html .= "
</select><br>";
echo $html;
?>
<button name="send_email" id="send_email" type="submit" class="btn btn-primary" style="margin-left: 36%;">Send Test</button>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$('#send_email').click(function(){
document.getElementById("send_email").innerHTML = "<span><i class=\'fa fa-spinner fa-spin\'></i> Sending...</span>";
document.getElementById('send_email').disabled = true;
var id = $(this).attr('autoid');
alert( $(this).attr('autoid'));
$.ajax({
type: 'POST',
url: "sendtest.php",
data: {autoid : id},
success: function(resultData)
{
alert(resultData)
$('#contactModal').modal('hide');
document.getElementById("send_email").innerHTML = "Send Test";
document.getElementById('send_email').disabled = false;
}
});
});
</script>
in sendtest.php:
<?php
// Initialize the session
session_start();
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
else if(isset($_POST))
{
$param_username = $_SESSION['username'];
$param_campaign = $_SESSION['campaign'];
$id = $_POST['autocampaign'];
echo "hello your id is...";
echo $id;
}
?>
I'm sorry if it have been posted very similar in the past, but this is a difficult situation I have been going through so I would like to get some help with this.
So what I am trying to do is when I click on a button to display on a modal and select a value, I click on a button again to get the ID autoid to post it via ajax and display the alert with the ID.
Can you please show me an example what is the correct way I could use to fetch the ID from the HTML tag called autoid so I can post it in ajax to display the ID in the alert?
Thank you.
EDIT: It didn't work when I try this:
<form action="" method="post">
<span style="font-size: 15px; color: #ccd5d9; float: left; margin-top: -1px"><a name="autoid" id="autoid" href="#contactModal" role="button" data-toggle="modal">Send a test</a> | <a name="autoid" id="autoid" href="/delete_id.php?id=<?php echo $autoid ?>"> Delete </a> | Copy to Draft | Settings</span>
</form>
in sendtest.php:
<?php
// Initialize the session
session_start();
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
else if(isset($_POST))
{
$param_username = $_SESSION['username'];
$param_campaign = $_SESSION['campaign'];
$id = $_POST['autoid'];
echo "hello your id is...";
echo $id;
}
?>
At all I get is hello your id is... in the alert.
UPDATE: Here is the full code:
<?php
// Initialize the session
session_start();
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
else
{
$link = mysqli_connect('localhost', 'mydbusername', 'mydbpassword', 'mydbname');
$param_username = $_SESSION['username'];
$autocampaign = $_SESSION["campaign"];
$auto_sql = "SELECT id, subject, day_cycle, enabled, delaysend FROM autore WHERE campaign ='$autocampaign' AND username ='$param_username'";
$results = mysqli_query($link, $auto_sql);
if (mysqli_num_rows($results) > 0)
{
while ($row = mysqli_fetch_array($results))
{
$autoid = $row["id"];
$autosubject = $row["subject"];
$autodaycycle = $row["day_cycle"];
$autoenabled = $row["enabled"];
$autodelay = $row["delaysend"];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style type="text/css">
.calendar-content {
float: left;
width: 100%;
min-height: 112px;
border: 1px solid #ccc;
position: relative;
margin-top: -1px;
}
</style>
<div class="calendar-content">
<div style="margin-left: 40px;margin-top: 20px; height: 40px;">
<span id="autosubject" style="font-size: 25px;color: #0c7ac0;float: left;">Subject: <?php echo $autosubject ?> </span><br>
<div style="margin-left: 35px; margin-top: 15px; height: 40px;">
<form action="" method="post">
<span style="font-size: 15px; color: #ccd5d9; float: left; margin-top: -1px"><a name="autoid" id="autoid" href="#contactModal" role="button" data-toggle="modal">Send a test</a> | <a name="deleteid" id="deleteid" href="/delete_id.php?id=<?php echo $autoid; ?>"> Delete </a> | Copy to Draft | Settings</span>
</form>
</div>
</div><br>
<!-- email Modal -->
<div id="contactModal" class="modal fade" style="margin-top: 12%;" tabindex="-1" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" style="height: 250px;">
<div class="modal-header" style="margin-bottom: 10px;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Send A Test Email</h3>
</div>
<div class="modal-body" style="height: 65%;">
<form action="" method="post">
<label class="label-control" value="">Send test message to email address:</label>
<select name="emails" id="emails" value="" style="width: 400px; margin-top: 10px; margin-bottom: 18px; margin-left: 60px;">
<option selected="selected" value='title'>Title</option>";
</select><br>
<button name="send_email" id="send_email" type="submit" class="btn btn-primary" style="margin-left: 36%;" data-auto-id="<?php echo $autoid; ?>">Send Test</button>
</form>
</div>
</div>
</div>
</div>
<?php
}
?>
<script type="text/javascript">
$(function() {
$('#send_email').click(function(e) {
$(this)
.html("<span><i class='fa fa-spinner fa-spin'></i> Sending...</span>")
.prop("disabled", true);
var id = $(this).data('deleteid');
$.ajax({
type: 'POST',
url: "sendtest.php",
data: {
deleteid: id
},
success: function(resultData) {
alert(resultData)
$('#contactModal').modal('hide');
$("#send_email")
.html("Send Test")
.prop("disabled", false);
}
});
});
});
</script>
</body>
</html>
In your sendtest.php you will want to change:
$id = $_POST['autocampaign'];
To the following:
$id = $_POST['autoid'];
Hope that helps.
Updated
var id = $(this).attr('autoid'); will fail since $(this) is a refernce to the Button Object and not the form. The <button> also does not have an attribute called autoid. Therefore, id will be null or undefined.
Where should id get it's value from?
$(function() {
$('#send_email').click(function(e) {
$(this)
.html("<span><i class='fa fa-spinner fa-spin'></i> Sending...</span>")
.prop("disabled", true);
var id = $(this).data('auto-id');
$.ajax({
type: 'POST',
url: "sendtest.php",
data: {
autoid: id
},
success: function(resultData) {
alert(resultData)
$('#contactModal').modal('hide');
$("#send_email")
.html("Send Test")
.prop("disabled", false);
}
});
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="calendar-content">
<div style="margin-left: 40px;margin-top: 20px; height: 40px;">
<span id="autosubject" style="font-size: 25px;color: #0c7ac0;float: left;">Subject: <?php echo $autosubject ?> </span><br>
<div style="margin-left: 35px; margin-top: 15px; height: 40px;">
<form action="" method="post">
<span style="font-size: 15px; color: #ccd5d9; float: left; margin-top: -1px"><a name="autoid" id="autoid" href="#contactModal" role="button" data-toggle="modal">Send a test</a> | <a name="autoid" id="autoid" href="/autoresponder/delete_autoresponder.php?id=<?php echo $autoid; ?>"> Delete </a> | Copy to Draft | Settings</span>
</form>
</div>
</div><br>
<!-- email Modal -->
<div id="contactModal" class="modal fade" style="margin-top: 12%;" tabindex="-1" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" style="height: 250px;">
<div class="modal-header" style="margin-bottom: 10px;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Send A Test Email</h3>
</div>
<div class="modal-body" style="height: 65%;">
<form action="" method="post">
<label class="label-control" value="">Send test message to email address:</label>
<select name="emails" id="emails" value="" style="width: 400px; margin-top: 10px; margin-bottom: 18px; margin-left: 60px;">
<option selected="selected" value='title'>Title</option>";
</select><br>
<button name="send_email" id="send_email" type="submit" class="btn btn-primary" style="margin-left: 36%;" data-auto-id="<?php echo $autoid; ?>">Send Test</button>
</form>
</div>
</div>
</div>
</div>
The following code is cleaned up. First, I added the data-auto-id attribute that contains the autoid from PHP. This can then be read and passed into the AJAX.
Also switched into all jQuery for consistency.
This is continuation of my question first question
Here i am drag and drop sticky notes from one to another. i have
<div class="rTable">
<div class="rTableRow">
<div id="a" title="Backog" class="rTableHead rTabletd"><strong>Backlog</strong></div>
<div id="a" title="WIP" class="rTableHead rTabletd"><span style="font-weight: bold;">WIP</span></div>
<div id="a" title="Testing" class="rTableHead rTabletd">Testing</div>
<div id="a" title="DOD" class="rTableHead rTabletd">DOD</div>
</div>
<div class="rTableRow rTableh" >
<div class="rTableCell"></div>
<div class="rTableCell"><a></a></div>
<div class="rTableCell"></div>
<div class="rTableCell"></div>
</div>
</div>
and sticky notes
<?php
foreach ($this->getallstores as $stories):
?>
<div id="draggable-<?php echo $stories['id']; ?>" class="draggable " onchange="javascript:position(this)" style="position:absolute; left: <?php echo $stories['_left']; ?>px; top: <?php echo $stories['_top']; ?>px">
<img class="pin" src="/manage/public/img/pin.png" alt="pin" />
<blockquote class="quote-box note-<?php echo $stories['color']; ?>">
<p class="quote-text" id="content-<?php echo $stories['id'];?>">
<?php echo $stories['message']; ?>
</p>
<hr>
<div class="blog-post-actions">
<p>
<button class="btn btn-primary popEdit pull-left" data-toggle='tooltip' title="Edit" onClick="popOverEdit(<?php echo $stories['id'];?>)" id="pop-<?php echo $stories['id'];?>"><span class="glyphicon glyphicon-edit"></span></button>
<div class="popover-markup blog-post-bottom" >
<div class="head hide">Edit</div>
<div class="content hide" id="popoverContent<?php echo $stories['id'];?>">
<div class="form-group">
<textarea id="<?php echo $stories['id']; ?>" class="quick" ><?php echo $stories['message']; ?></textarea>
</div>
<button data-vendor-id="" data-act="send" onClick="getText(<?php echo $stories['id'];?>)" class="btn btn-info save_notes">Save</button>
</div>
</div>
</p>
<p class="blog-post-bottom pull-right">
<a class="delete" href="?delete=<?php echo $stories['id']; ?>" style="float:right"> <button class="btn btn-danger" title="delete"><span class="glyphicon glyphicon-trash"></span></button> </a>
</p>
</div>
</blockquote>
</div>
<?php endforeach;?>
demo
my requirement is i want to drag and drop stickys and save to database.Now i have save position.is there any way to save column name?eg if drag sticky note from backlog to testing how can i get placed position name is testing?Please help me.
jquery
jQuery(function() {
jQuery( ".draggable" ).draggable({ containment: "#containment-wrapper", scroll: false ,
// Find position where image is dropped.
stop: function(event, ui) {
// Show dropped position.
var id=$(this).attr('id');
var ti=$(".rTabletd").attr("title");
var Stoppos = $(this).position();
model = {
id:id,
left: Stoppos.left,
top: Stoppos.top
};
$.ajax({
url: "/scrum/save",
type: "post",
data: model,
success: function(data){
jQuery.HP({
title: "Success!",
message: "Saved..."
});
},
error:function(){
// alert('error is saving');
}
});
}
});
});
You can create an array and use the droppable index position to select the array value.
var table = ['Backlog', 'WIP', 'Testing', 'DOD'];
$(".rTableCell > div").draggable();
$(".rTableCell").droppable({
drop: function(event, ui) {
var table = ['Backlog', 'WIP', 'Testing', 'DOD'];
var droppedOn = event.target;
alert(table[$(droppedOn).index()]);
}
});
.rTableHead,
.rTableCell {
display: inline-block;
width: 23%;
}
.rTableCell {
border: 1px solid black;
height: 100vh;
}
.rTableCell>div {
background-color: blue;
padding: 5px;
color: white;
border-radius: 5px;
margin: 5px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<div class="rTable">
<div class="rTableRow">
<div id="backlog" title="Backog" class="rTableHead rTabletd"><strong>Backlog</strong></div>
<div id="WIP" title="WIP" class="rTableHead rTabletd"><span style="font-weight: bold;">WIP</span></div>
<div id="TESTING" title="Testing" class="rTableHead rTabletd"><span style="font-weight: bold;">Testing</span></div>
<div id="DOD" title="DOD" class="rTableHead rTabletd"><span style="font-weight: bold;">DOD</span></div>
</div>
<div class="rTableRow rTableh">
<div class="rTableCell">
<div>
Item 1
</div>
</div>
<div class="rTableCell">
<div>
Item 2
</div>
</div>
<div class="rTableCell">
<div>
Item 3
</div>
</div>
<div class="rTableCell">
<div>
Item 4
</div>
</div>
</div>
</div>
this code is not working to display data from mysql using php and angularjs
html code -
<div class="container" ng-app="shoppingcart"
ng-controller="shoppingcartcontroller"> <div class="row " >
<div class="box col-md-3" style="margin-top: 20px;" ng-repeat="p in
products">
<div style="border: 1px solid #ccc; background-color: #f4f5f6">
<img src="/images/{{p.image}}.jpg" class="img img-responsive">
<h3>{{p.name}}</h3>
<h3>{{p.price}}</h3>
</div> </div>
</div> </div>
angular code -
<script >
var app=angular.module("shoppingcart",[]);
app.controller("shoppingcartcontroller",function($http,$scope){
$scope.loadproduct=function(){
$http.get("fetch.php").success(function(data){
$scope.products=data;
});
};
});
</script>
A simple example
HTML
<div ng-repeat="p in products">
{{p.name}}
{{p.price}}
</div>
JS
var app=angular.module("shoppingcart",[]);
app.controller("shoppingcartcontroller",function($http,$scope){
$scope.loadproduct=function(){
$http.get("fetch.php").then(function(response){
$scope.products=response.data;
});
};
});
Sorry, I have found lots of answers here regarding modals and jQuery, but I cant find anything that helps me. I have a form that has photos. People should be able to click on the photo and it would open a larger version in a modal window. For the life of me, I can't figure out how to pass the value of the photo name to the modal. Here is what I have:
php/HTML:
<?php
$imgno = 1;
$dir = "memberphotos/$id/";
$qry = "SELECT PhotoName, Visible, Likes FROM photolist WHERE UserID = " . $id;
if ($result = mysqli_query($GLOBALS['link'], $qry)) {
while ($row = $result->fetch_assoc()) {
?>
<div class="col-md-3 col-sm-4 col-xs-6">
<div class="album-image">
<a href="#" class="thumb" data-action="edit" src='<?php $dir.$row['PhotoName']; ?>'>
<img src="<?php echo $dir . $row['PhotoName'] . "_thumb.jpg"; ?>"
class="img-responsive"/>
</a>
<a href="#" class="name">
<i class="fa-heart-o"> <?php if (!empty($row['Likes'])) {echo $row['Likes']." Likes";} ?> </i>
</a>
<div class="image-options">
<i class="fa-heart-o"></i>
</div>
</div>
</div>
<?php
$imgno = $imgno+1;}
}
?>
Now for the jquery:
<script type="text/javascript">
// Sample Javascript code for this page
jQuery(document).ready(function ($) {
// Edit Modal
$('.gallery-env a[data-action="edit"]').on('click', function (ev) {
var id = ('data-id');
ev.preventDefault();
$("#gallery-image-modal").modal('show');
});
});
</script>
Now, the code... I hard coded an image name into the img src to make sure it works, which it does. I'm just trying to get the photo name from the database, stored for each photo and passed to the modal.
<div class="modal fade" id="gallery-image-modal" >
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-gallery-image">
<img src="<?php echo $dir . '2017-02-28_1_B828A.jpg'; ?>" class="img-responsive"/>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<a href="#" class="name">
<i class="fa-heart"> <?php echo $row['Likes']; ?> Likes</i>
</a>
</div>
</div>
</div>
<?php if ($id == $_SESSION['uid']) {?>
<div class="modal-footer modal-gallery-top-controls">
<button type="button" class="btn btn-xs btn-white" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-xs btn-info">Set as Main</button>
<button type="button" class="btn btn-xs btn-red">Delete image</button>
</div>
<?php } ?>
</div>
</div>
</div>
I can't figure this out... a little help for a humble learning coder?
Using .on() events isn't always the best solution. You also don't need to wrap the image inside of an a tag.
<img src="<?php echo $dir . $row['PhotoName'] . "_thumb.jpg"; ?> onclick="openImgModal('<?php echo $dir . $row['PhotoName']; ?>')" class="img-responsive"/>
Javascript:
function openImgModal(img_src)
{
$('.modal-gallery-image').html('<img src="'+img_src+'" class="img-responsive" />');
$("#gallery-image-modal").modal('show');
}
maybe add some CSS to indicate the image is clickable
.img-responsive
{
cursor: pointer;
}
Here is an easy way that does not include inline javascript
HTML
<div class="cover"> </div>
<div class="modalPhoto">
<img src="" />
</div>
CSS (can adjust this for your needs)
.cover {
position:fixed;
top:0;
left:0;
background:rgba(0,0,0,0.6);
z-index:9997;
width:100%;
height:100%;
display:none;
}
body.open .cover {
display:block;
}
.modalPhoto {
position:fixed;
z-index:9998;
width:680px;
height:550px;
background:#fff;
text-align:center;
box-shadow:0 0 15px -5px rgba(0,0,0,0.8);
top:50%;
margin-top:-1500px;
left:50%;
margin-left:-350px;
-webkit-transition:800ms margin-top ease-in-out;
transition:800ms margin-top ease-in-out;
overflow:hidden;
border:10px solid #fff;
}
body.open .modalPhoto {
margin-top:-285px;
}
jQuery
$('.gallery-env a img').on('click', function(e) {
var photo = $(this).data('src');
$('.modalPhoto').find('img').attr('src', photo);
$('body').addClass('open');
});
$('.cover').on('click',function() {
$('body').removeClass('open');
});
Let me know if any of this doesn't make sense
I added a hover effect on a button. The code effect worked perfectly until I added some PHP code inside my page. Everything except the hover effect is working fine. It tried to understand the problem by using console but got no hint.
Here's my code:
CSS:
#secondary-content
{
position: relative;
top: 100vh;
}
#write-blog
{
position: relative;
top: -50%;
z-index: 3;
}
.ghost-button
{
display: inline-block;
width: 200px;
padding: 8px;
color: #fff;
border: 2px solid #fff;
text-align: center;
outline: none;
text-decoration: none;
}
.ghost-button:hover, .ghost-button:active
{
background-color: #fff;
color: #000;
transition: background-color 0.3s ease-in, color 0.3s ease-in;
}
Here's the code inside my body:
<div class="slider fullscreen" data-indicators="false">
<ul class="slides">
<li>
<img src="Includes/images/map2.jpg">
<div class="caption left-align">
<h3 class="light white-text">History doesn't repeats itself,<br>but it does rhyme.</h3>
</div>
</li>
<li>
<div class="caption right-align">
<h1 class="light white-text">First solve the problem.<br>Then, write the code.</h1>
</div>
<img src="Includes/images/sublime_text.jpeg"> <!-- random image -->
</li>
<li>
<div class="caption center-align">
<h4 class="light white-text">Art speaks where words are unable to explain.</h4>
</div>
<img src="Includes/images/art1.jpg">
</li>
<li>
<img src="Includes/images/music2.jpg">
<div class="caption right-align">
<h5 class="light grey-text text-lighten-3">Where words fail, Music speaks.</h5>
</div>
</li>
<li>
<div class="caption left-align">
<h4 class="light white-text">Science is the poetry of<br>reality.</h4>
</div>
<img src="Includes/images/science.jpg"> <!-- random image -->
</li>
</ul>
<div id="write-blog" class="center-align">
<a class="ghost-button" href="">WRITE A BLOG</a>
</div>
</div>
<div id="secondary-content">
<div class="container">
<?php
$blog = DB::getInstance()->get('blogs', array('deletion_status', '=', '0'));
if($blogs = $blog->fetchRecords(2))
{
foreach($blogs as $blog)
{
$date=strtotime($blog->created_on); // changing the format of timestamp fetched from the database, converting it to milliseconds
echo
"<div class='section'>
<div class='row'>
<div class='col s2'>
<blockquote>".
date('M', $date)."<br>".
date('Y d', $date).
"</blockquote>
</div>
<div class='col s8'>
<h5>".ucfirst($blog->title)."</h5>
<h6>".ucfirst($blog->description)."</h6><br>
<div class='row'>
<div class='col s1'>
<i class='material-icons' style='color:grey'>remove_red_eye</i>
</div>
<div class='col s1'>
{$blog->views}
</div>
<div class='col s1 offset-s2'>
<i class='material-icons' style='color:grey'>thumb_up</i>
</div>
<div class='col s1'>
{$blog->likes}
</div>
<div class='col s1 offset-s2'>
<i class='material-icons' style='color:grey'>thumb_down</i>
</div>
<div class='col s1'>
{$blog->dislikes}
</div>
</div>
<div class='divider'></div>
</div>
</div>
</div>";
}
}
?>
</div>
<script src="Includes/js/jquery.min.js"></script>
<script type="text/javascript" src="Includes/js/materialize.min.js"></script>
<script>
$(document).ready(function(){
$('.slider').slider();
});
</script>
The code below the div having id 'secondary-content' is also working fine. What wrong am I doing here?