asset/CSS/style-boots.css?"> -6ren">
gpt4 book ai didi

javascript - 在 php 和 jquery 上发出通知

转载 作者:行者123 更新时间:2023-12-03 04:24:06 25 4
gpt4 key购买 nike

enter image description here

<!DOCTYPE html>
<html>
<head>
<title><?php echo $title ?></title>

<!--Logo di title bar -->
<link rel="shortcut icon" href="<?php echo base_url();?>asset/img/logokominfo.png"/>

<!--CSS-->
<link rel="stylesheet" href="<?php echo base_url();?>asset/CSS/style-boots.css?<?php echo time(); ?>">
<link rel="stylesheet" href="<?php echo base_url();?>asset/CSS/style-pengumuman.css?<?php echo time(); ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<style type="text/css">
body {
background: #f7f7f7;
font-family: 'Montserrat', sans-serif;
}

.dropzone {
background: #fff;
border: 2px dashed #ddd;
border-radius: 5px;
}

.dz-message {
color: #999;
}

.dz-message:hover {
color: #464646;
}

.dz-message h3 {
font-size: 200%;
margin-bottom: 15px;
}

</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<link rel="stylesheet" type="text/css" href="../asset/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../asset/css/style-profile.css?<?php echo time(); ?>">

<script>
$('#tab4primary').click(function(){
<?php $notif= ''?>
});
</script>

</head>
<body>

<nav id="sticker" class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<a class="menu"><i class="fa fa-bars" id="menu_icon"></i></a>
<a class="navbar-brand" href="#">
<img src="<?php echo base_url();?>asset/img/logo_emagang.png" class="img-responsive" />
</a>
</div><!--navbar-header close-->

<div class="collapse navbar-collapse drop_menu" id="content_details">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span><?php echo $userData['nama_lengkap'] ?><span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="dashboard"><i class="fa fa-user" aria-hidden="true"></i> Profile</a>
<li><a href="view_ubah_data-profile"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Ubah Profile</a></li>
<li><a href="view_ubah_password"><i class="fa fa-key" aria-hidden="true"></i> Ubah Password</a></li>
<li><a href="users/logout"><i class="fa fa-sign-out" aria-hidden="true"></i> Logout</a>
</li>
</ul>
</li>
</ul><!--navbar-right close-->
</div><!--collapse navbar-collapse drop_menu close-->
</div><!--container-fluid close-->
</nav><!--navbar navbar-inverse close-->


<br>
<br>


<section>

<div class="container" style="margin-top: 10px;">
<div class="profile-head">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-12"><br><br><br><br><br><br>
<h6>
<img src="<?php echo base_url();?>uploads/images/<?php echo $userData['nama_foto']."?".time(); ?>">
<br><br><?php echo $userData['nama_lengkap'] ?><br><br>
</h6>
</div><!--col-md-4 col-sm-4 col-xs-12 close-->


<div class="col-md-8 col-sm-5 col-xs-12"><br><br><br><br><br>
<h5><?php echo $userData['nama_lengkap'] ?></h5>
<p>Siswa / Mahasiswa </p>
<ul>
<li><span class="glyphicon glyphicon-info-sign"></span> <?php echo $userData['tanggal_lahir'] ?></li>
<li><span class="glyphicon glyphicon-book"></span> <?php echo $userData['nama_institusi'] ?></li>
<li><span class="glyphicon glyphicon-home"></span> <?php echo $userData['alamat'] ?></li>
<li><span class="glyphicon glyphicon-phone"></span> <?php echo $userData['no_telpon'] ?></li>
<li><span class="glyphicon glyphicon-envelope"></span><?php echo $userData['email'] ?></li>

</ul>
</div><!--col-md-8 col-sm-8 col-xs-12 close-->
</div>
</div><!--profile-head close-->
</div><!--container close-->



<dir class="container">
<?php

// $id = $this->session->flashdata('id');
$salah = $this->session->flashdata('salah');
$berhasil = $this->session->flashdata('berhasil');
?>


<!--error message-->
<?php echo $salah['error'];?>
<?php echo $berhasil;?>
<?php
$status = $userData['status'];
if($status == 'diterima'){
$notif = 'baru';
}
?>


<div class="panel with-nav-tabs panel-primary">
<div class="panel-heading">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1primary" data-toggle="tab">
<span class="glyphicon glyphicon-user"></span> Personal Data
</a></li>
<li><a href="#tab2primary" data-toggle="tab">
<i class="fa fa-university" aria-hidden="true"></i> Pendidikan
</a></li>
<li><a href="#tab3primary" data-toggle="tab">
<i class="fa fa-file" aria-hidden="true"></i> Daftar Riwayat Hidup
</a></li>
<li>
<a href="#tab4primary" data-toggle="tab">
<span class="badge quote-badge" id="pemberitahuan"><?php echo $notif ?></span>
<i class="fa fa-bullhorn" aria-hidden="true"></i> Pengumuman
</a></li>
</ul>
</div>
<div class="panel-body">
<div class="tab-content">
<div class="tab-pane fade in active" id="tab1primary">
<div class="row">
<div class="col-md-8">
<table class="table table-striped">
<thead>
<tr>
<th>Data Akun</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Email</td>
<td>:</td>
<td>
<?php echo $userData['email'] ?>
</td>
</tr>
<tr>
<td>tanggal daftar</td>
<td>:</td>
<td>
<?php echo $userData['tanggal_daftar'] ?>
</td>
</tr>
</tbody>


<thead>
<tr>
<th>Tujuan Magang</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Satuan kerja</td>
<td>:</td>
<td>
<?php echo $userData['nama_satuan_kerja'] ?>
</td>
</tr>
<tr>
<td>Unit kerja</td>
<td>:</td>
<td>
<?php echo $userData['nama_unit_kerja'] ?>
</td>
</tr>
<tr>
<td>Tanggal Mulai</td>
<td>:</td>
<td>
<?php
$tanggal_mulai = $userData['tanggal_mulai'];
echo date('d F Y', strtotime($tanggal_mulai));
// $input = $userData['tanggal_mulai'];
// $date = strtotime($input);
// $day = date('d',$date);
// $month = date('m',$date);
// $year = date('Y',$date);
// echo $month;
?>
</td>
</tr>
<tr>
<td>Tanggal Selesai</td>
<td>:</td>
<td>
<?php
$tanggal_lahir = $userData['tanggal_selesai'];
echo date('d F Y', strtotime($tanggal_lahir));
?>
</td>
</tr>
</tbody>

<thead>
<tr>
<th>Data Pribadi</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Nama Lengkap</td>
<td>:</td>
<td>
<?php echo $userData['nama_lengkap'] ?>
</td>
</tr>
<tr>
<td>Jenis Kelamin</td>
<td>:</td>
<td>
<?php echo $userData['jenis_kelamin'] ?>
</td>
</tr>
<tr>
<td>Tanggal Lahir</td>
<td>:</td>
<td>
<?php
$tanggal_lahir = $userData['tanggal_lahir'];
echo date('d F Y', strtotime($tanggal_lahir));

?>
</td>
</tr>
<tr>
<td>Alamat</td>
<td>:</td>
<td>
<?php echo $userData['alamat'] ?>
</td>
</tr>
<tr>
<td>No telpon</td>
<td>:</td>
<td>
<?php echo $userData['no_telpon'] ?>
</td>
</tr>

</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="tab2primary">
<table class="table table-striped">
<thead>
<tr>
<th>Pendidikan</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Tingkat Pendidikan</td>
<td>:</td>
<td>
<?php echo $userData['tingkat_pendidikan'] ?>
</td>
</tr>
<tr>
<td>Nama Institusi</td>
<td>:</td>
<td>
<?php echo $userData['nama_institusi'] ?>
</td>
</tr>
<tr>
<td>Jurusan</td>
<td>:</td>
<td>
<?php echo $userData['jurusan'] ?>
</td>
</tr>
<tr>
<td>Nilai Raport Rata-Rata/ IPK</td>
<td>:</td>
<td>
<?php echo $userData['nilai'] ?>
</td>
</tr>
<tr>
<td>Alamat Institusi</td>
<td>:</td>
<td>
<?php echo $userData['alamat_institusi'] ?>
</td>
</tr>
<tr>
<td>No telpon Institusi</td>
<td>:</td>
<td>
<?php echo $userData['no_telpon_institusi'] ?>
</td>
</tr>

</tbody>
</table>
</div>
<div class="tab-pane fade" id="tab3primary">
<div class="row">
<div class="col-md-4">
<div class="alert alert-warning alert-dismissable fade in">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>catatan :</strong> Untuk melihat CV langsung diprofile disarankan untuk menonaktifkan software bantuan download, seperti: IDM Dll.
</div>

<div class="bs-calltoaction bs-calltoaction-primary">
<div class="row">
<div class="col-md-12">
<p>Daftar Riwayat Hidup</p>
<div class="cta-button">
<a href="<?php echo base_url();?>uploads/cv/<?php echo $userData['nama_cv']."?".time(); ?>" class="btn btn-lg btn-block btn-primary"><span class="glyphicon glyphicon-download-alt"></span> Donwload daftar riwayat hidup</a>
</div>
<p style="font-size: 12px">Terakhir Di Update : <?php
$tanggal_update_cv = $userData['tanggal_update_cv'];
echo date('d F Y', strtotime($tanggal_update_cv)); ?></p>

</div>
</div>
</div>

</div>
<div class="col-md-8">
<center>
<h4 class="name">Ubah CV / Daftar Riwayat Hidup</h4>
<hr class="whitehr">
</center>

<div id="content">
<div class="row">
<div class="col-md-7"><br>
<div class="dropzone">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<center><br><br><br><br>
<h3>Upload file disini</h3> ukuran <strong>maksimal</strong> 2MB
<?php echo form_open_multipart('users/updatecv');?>
<input type="hidden" id="id" name="id" value="<?php echo $userData['id'] ?>">
<input type="hidden" id="nama_cv" name="nama_cv" value="<?php echo $userData['nama_cv'] ?>">
<input type="file" style="margin-left : 50px" name="document" id="files" accept=".doc, .docx, application/msword, application/pdf" required>
<button style="margin-top : 20px" type="submit" value="Upload" name="submit" class="btn btn-primary btn-lg">
<i class="fa fa-upload" aria-hidden="true"></i>
upload
</button>
<?php echo form_close();?>
</center><br><br><br><br>
</div>
</div>
</div>
</div>
<div class="col-md-5">
Contoh CV(Daftar Riwayat Hidup)
<a href="<?php echo base_url();?>asset/doc/contoh_cv.doc">
<img src="<?php echo base_url();?>asset/doc/contoh_cv.png" style="width: 80%">
</a>
<div class="col-md-10">
<div class="cta-button">
<a href="<?php echo base_url();?>asset/doc/contoh_cv.doc" class="btn btn-lg btn-block btn-info">Download Template CV</a>
</div>
</div>
</div>
</div>

</div>
</div>
</div>


</div>


<div class="tab-pane fade" id="tab4primary">

<center>
<h1 class="name">Pengumuman</h1>
<hr class="whitehr">
</center>
<div class="col-sm-12 col-md-12 col-xm-12">
<div class="bs-calltoaction bs-calltoaction-warning">
<div class="row">
<div class="col-sm-2 col-md-3 col-xs-8">
<img src="<?php echo base_url();?>asset/img/alur-pendaftaran/6.png" class="img-responsive">
</div>
<div class="col-md-6 cta-contents">
<h3 class="cta-title">Waktu Magang Anda Telah Selesai</h3>
<hr>
<div class="cta-desc">

</div>
</div>
<div class="col-md-3 cta-button">
<a href="Sertifikat/Sertifikat_pdf" class="btn btn-lg btn-block btn-warning">Download Sertifikat</a>
</div>
</div>
</div>
<?php
$status = $userData['status'];
if($status == 'diterima'){
$this->load->view('dashboard/diterima');
}?>

<blockquote class="quote-box"><br>
<div class="col-sm-2 col-md-3 col-xs-8">
<img src="<?php echo base_url();?>asset/img/alur-pendaftaran/3.png" class="img-responsive">
</div>

<p class="quotation-mark">“</p>

<hr>
<div class="blog-post-actions">
<p class="blog-post-bottom pull-left">
Pengumuman
</p>
<p class="blog-post-bottom pull-right">
<span class="badge quote-badge">Biro Kepegawaian Dan Organisasi</span>
</p>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</dir>

<?php $this->load->view('footer');?>

</section><!--section close-->

<script type="text/javascript" src="../asset/js/jquery.min.js"></script>
<script type="text/javascript" src="../asset/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../asset/js/profile.js"></script>
<script type="text/javascript" src="../asset/js/pemberitahuan.js"></script>


</body>
</html>

当我单击或被单击按钮通知时,我尝试使用 php 发出通知,通知将被我制作的 jquery 或 js 删除,但我在那里得到堆栈,如何在单击通知时删除通知。

这是我为删除通知而编写的代码

<script>
$('#tab4primary').click(function(){
<?php $notif= ''?>
});
</script>

这是我为显示通知编写的代码

<?php
$status = $userData['status'];//this i get from database
if($status == 'diterima'){
$notif = 'new';
}
?>

通知只是文本,所以当 $status == diterima 时,它将显示新的,当我单击通知按钮时,新的文本必须被删除或消失,但我在那里有库存

最佳答案

正如 Berend de Groot 所建议的,一旦页面加载(并且 php 停止执行任何操作),您需要保持在 JavaScript 上下文中。尝试更改直接显示消息的 HTML :

<script>
$('#tab4primary').click(function(){
$('selectorWhereTheNotifTextIsWrittenInDOm').empty();
});
</script>

您可能想要尝试 hide() 而不是清空,具体取决于您的 DOM 和预期行为。

编辑:使用您发布的 HTML,答案现在是:

<script>
$('#tab4primary').click(function(){
$('#pemberitahuan').empty();
});
</script>

同样的事情适用于 hide() 而不是empty()

编辑2:尝试:

<script>
$(document).ready(function() {
$('#tab4primary').click(function(){
$('#pemberitahuan').hide();
});
});
</script>

并确保删除:

<script>
$('#tab4primary').click(function(){
<?php $notif= ''?>
});
</script>

编辑3:如果您尝试的话,#tab4primary 毕竟似乎不是正确的触发元素:

<script>
$('#pemberitahuan').click(function(){
$('#pemberitahuan').hide();
});
</script>

您应该看到发生了一些事情。现在的问题是选择适当的触发器和目标,在大多数情况下,它们应该是不同的。

关于javascript - 在 php 和 jquery 上发出通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43819822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com